first commit

master
km0 2 years ago
commit b8252e54b1

BIN
.DS_Store vendored

Binary file not shown.

@ -0,0 +1,36 @@
let categories = {
collect: {
title: "Collection of Data",
keywords: ["data", "collect"],
},
third: {
title: "Usage of Data",
keywords: ["share", "third", "companies", "party"],
},
location: {
title: "Location",
keywords: ["location", "position", "coordinate"],
},
permission: {
title: "Permission and Consent",
keywords: ["permission", "consent"],
},
upload: {
title: "Uploaded Contents",
keywords: ["upload", "content"],
},
suspension: {
title: "Suspension of the account",
keywords: ["suspension", "termination", "ban", "suspend", "disable", "account", "breached"],
},
};
let selected = ["collect", "third", "location"];
chrome.runtime.onInstalled.addListener(() => {
chrome.storage.sync.set({ selected, categories });
console.log(
"The default selected categories are:",
selected.map((slug) => categories[slug].title).join(", ")
);
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

@ -0,0 +1,29 @@
{
"name": "Parse Policies",
"description": "An extension to parse privacy policies",
"version": "0.1",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
},
"permissions": [
"storage",
"activeTab",
"scripting"
],
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "/images/icon_16.png",
"32": "/images/icon_32.png",
"48": "/images/icon_48.png",
"128": "/images/icon_128.png"
}
},
"icons": {
"16": "/images/icon_16.png",
"32": "/images/icon_32.png",
"48": "/images/icon_48.png",
"128": "/images/icon_128.png"
}
}

@ -0,0 +1,33 @@
body {
width: 200px;
}
button {
height: 30px;
width: 30px;
outline: none;
border-radius: 2px;
cursor: pointer;
border: 1px solid currentColor;
}
button:active {
background-color: currentColor;
}
button.current {
box-shadow: 0 0 0 2px white,
0 0 0 4px black;
}
h1, h2 {
font-size: 1rem;
margin: 8px 0;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="popup.css" />
<script src="popup.js" defer></script>
</head>
<body>
<h1>Parse Policies</h1>
<button id="activate"></button>
<div>
<h2>Selected categories</h2>
<ul id="selected-list"></ul>
</div>
</body>
</html>

@ -0,0 +1,46 @@
// Sync the selected categories in the popup
chrome.storage.sync.get(["categories", "selected"], (result) => {
let categories = result.categories;
let selected = result.selected;
listCategories(categories, selected);
});
const listCategories = function (categories, selected) {
let selectedList = document.getElementById("selected-list");
for (const category of selected) {
item = document.createElement("li");
item.innerHTML = categories[category].title;
selectedList.appendChild(item);
}
};
const activate = document.getElementById("activate");
activate.addEventListener("click", async () => {
let [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
chrome.scripting.executeScript({
target: { tabId: tab.id },
function: highlightSelected,
});
});
function highlightSelected() {
chrome.storage.sync.get(["categories", "selected"], (result) => {
for (category of result.selected) {
result.categories[category].keywords.forEach((keyword) => {
let findings = contains("*", keyword);
if (findings.length) {
console.log(findings);
}
});
}
});
function contains(selector, text) {
var elements = document.querySelectorAll(selector);
return Array.prototype.filter.call(elements, function (element) {
return RegExp(text).test(element.textContent);
});
}
}

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<p>
Tempor dolore voluptate aute velit. Anim laboris deserunt ut Lorem sunt. Occaecat
consectetur ex proident culpa consectetur aliqua minim nulla consequat amet enim. Ipsum
excepteur fugiat reprehenderit laboris sint.
</p>
<p>Location tempor eheh ahah</p>
<p>Usage of data</p>
</body>
</html>
Loading…
Cancel
Save