-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsafebrowse.js
32 lines (28 loc) · 1.6 KB
/
safebrowse.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
document.addEventListener("DOMContentLoaded", () => {
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
chrome.runtime.sendMessage({ action: "thirdPartyRequests", tabId: tabs[0].id }, (response) => {
const thirdPartyConnectionsList = document.getElementById("third-party-connections");
response.forEach(hostname => {
const listItem = document.createElement("li");
listItem.textContent = hostname;
thirdPartyConnectionsList.appendChild(listItem);
});
});
chrome.runtime.sendMessage({ action: "countCookies", domain: new URL(tabs[0].url).hostname }, (response) => {
const content = `Total: ${response.total}, First-party: ${response.firstParty}, Third-party: ${response.thirdParty}, Session: ${response.session}, Persistent: ${response.persistent}`;
document.getElementById("cookie-count").textContent = content;
});
});
chrome.runtime.sendMessage({ action: "verifyLocalStorage" }, (response) => {
const localStorageDetectedSpan = document.getElementById("local-storage");
if (response.error) {
localStorageDetectedSpan.textContent = response.error;
} else {
const storageCount = response.data.localStorageCount;
localStorageDetectedSpan.textContent = storageCount > 0 ? `Detected (${storageCount} items)` : "None";
}
});
chrome.runtime.sendMessage({ action: "evalSafetyScore" }, (response) => {
document.getElementById("privacy-score").textContent = response.score;
});
});