commit b8252e54b1cbeeb0e7fcc4ff368e49cc7cb56dbf Author: kam (from the studio) Date: Wed May 18 20:58:45 2022 +0200 first commit diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..3b2dbf8 Binary files /dev/null and b/.DS_Store differ diff --git a/background.js b/background.js new file mode 100644 index 0000000..460837a --- /dev/null +++ b/background.js @@ -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(", ") + ); +}); diff --git a/images/icon_128.png b/images/icon_128.png new file mode 100644 index 0000000..6b7ecb0 Binary files /dev/null and b/images/icon_128.png differ diff --git a/images/icon_16.png b/images/icon_16.png new file mode 100644 index 0000000..08cde15 Binary files /dev/null and b/images/icon_16.png differ diff --git a/images/icon_32.png b/images/icon_32.png new file mode 100644 index 0000000..15da1c5 Binary files /dev/null and b/images/icon_32.png differ diff --git a/images/icon_48.png b/images/icon_48.png new file mode 100644 index 0000000..7270784 Binary files /dev/null and b/images/icon_48.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..b09a6e8 --- /dev/null +++ b/manifest.json @@ -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" + } +} \ No newline at end of file diff --git a/popup.css b/popup.css new file mode 100644 index 0000000..6230bdb --- /dev/null +++ b/popup.css @@ -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; +} \ No newline at end of file diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..0038405 --- /dev/null +++ b/popup.html @@ -0,0 +1,15 @@ + + + + + + + +

Parse Policies

+ +
+

Selected categories

+ +
+ + diff --git a/popup.js b/popup.js new file mode 100644 index 0000000..30a5229 --- /dev/null +++ b/popup.js @@ -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); + }); + } +} diff --git a/test.html b/test.html new file mode 100644 index 0000000..f263d74 --- /dev/null +++ b/test.html @@ -0,0 +1,20 @@ + + + + + + + Document + + +

+ 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. +

+ +

Location tempor eheh ahah

+ +

Usage of data

+ +