diff --git a/manifest.json b/manifest.json
index c1220db..1d346e8 100644
--- a/manifest.json
+++ b/manifest.json
@@ -7,7 +7,7 @@
"sidebar_action": {
"default_title": "ICD Skaner",
- "default_panel": "sidebar.html",
+ "default_panel": "sidebar/sidebar.html",
"default_icon": "sidebar_icon.png"
},
"icons": {
diff --git a/popup.html b/popup.html
deleted file mode 100644
index 689799c..0000000
--- a/popup.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/popup.js b/popup.js
deleted file mode 100644
index 367df1b..0000000
--- a/popup.js
+++ /dev/null
@@ -1,90 +0,0 @@
-output.innerHTML = "loading...";
-let tabid = null;
-let tab = null;
-let memory = null;
-
-chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
- var currTab = tabs[0];
- if (currTab) {
- // Sanity check
- /* document.write(JSON.stringify(currTab)); */
- tabid = currTab.id;
- tab = currTab;
- }
-});
-
-function atLeastOneCookiedRequest(requests) {
- return requests.some((request) => request.has_cookie);
-}
-
-function sortByShorthost(tabdata) {
- return Object.entries(tabdata).sort(([shorthost1], [shorthost2]) => {
- return shorthost1 > shorthost2;
- });
-}
-
-function extractAllCookies(requests) {
- return Array.from(new Set(requests.map((request) => request.cookie))).filter(
- (cookie) => cookie !== undefined
- );
-}
-
-function render(memory = {}) {
- let output_txt = "";
- if (!memory?.[tabid]) {
- output_txt = "No data for this tab";
- output.innerHTML = output_txt;
- return;
- }
- output_txt = /* HTML */ `
- Część Twojej historii przeglądania została wysłana przez stronę ${tab.url}
- do:
-
- `;
- sortByShorthost(memory[tabid]).forEach(([shorthost, requests]) => {
- output_txt += /* HTML */ `
-
- ${shorthost}
- ${atLeastOneCookiedRequest(requests)
- ? /* HTML */ `🍪
- ${extractAllCookies(requests)
- .map((cookie) => `${cookie}
`)
- .join("\n")}
-
`
- : ""}
-
- `;
- });
- output_txt += "";
- output.innerHTML = output_txt;
-}
-
-chrome.runtime.sendMessage({ msg: "get_memory" }, (_memory) => {
- memory = _memory;
- render(memory);
-});
-
-clean.onclick = () => {
- chrome.runtime.sendMessage({ msg: "clear_memory" }, (memory_) => {
- memory = memory_;
- render(memory);
- });
-};
-
-function getDate() {
- return new Date().toISOString().split("T")[0];
-}
-
-copy_harsh.onclick = () => {
- const text_html = harsh_email_template();
- navigator.clipboard.write([
- new ClipboardItem({ "text/plain": text_html, "text/html": text_html }),
- ]);
-};
-
-copy_polite.onclick = () => {
- const text_html = polite_email_template();
- navigator.clipboard.write([
- new ClipboardItem({ "text/plain": text_html, "text/html": text_html }),
- ]);
-};
diff --git a/request-cluster.ts b/request-cluster.ts
index 9d5a659..ace0c68 100644
--- a/request-cluster.ts
+++ b/request-cluster.ts
@@ -5,6 +5,7 @@ export type Sources = "cookie" | "pathname" | "queryparams" | "header";
import { TCString, TCModel } from "@iabtcf/core";
import { isJSONObject, isURL, parseToObject } from "./util";
+import memory from "./memory";
const id = (function* id() {
let i = 0;
@@ -77,17 +78,33 @@ export class StolenDataEntry {
getParsedValue(key_path: string): string | Record {
let object = StolenDataEntry.parseValue(this.value);
- console.log("key_path", key_path);
for (const key of key_path.split(".")) {
if (key === "") continue;
- console.log(key, object[key]);
object = StolenDataEntry.parseValue(object[key]);
}
return object;
}
- addMarkedValue(key: string) {
+ addMark(key: string) {
this.markedKeys.push(key);
+ memory.emit("change"); // to trigger rerender
+ }
+
+ hasMark(key: string) {
+ return this.markedKeys.some((k) => k == key);
+ }
+
+ removeMark(key: string) {
+ this.markedKeys = this.markedKeys.filter((e) => e != key);
+ memory.emit("change"); // to trigger rerender
+ }
+
+ toggleMark(key: string) {
+ if (this.hasMark(key)) {
+ this.removeMark(key);
+ } else {
+ this.addMark(key);
+ }
}
}
@@ -131,8 +148,22 @@ export class MergedStolenDataEntry {
);
}
- addMarkedValue(key: string) {
- this.entries.forEach((entry) => entry.addMarkedValue(key));
+ addMark(key: string) {
+ this.entries.forEach((entry) => entry.addMark(key));
+ }
+
+ getMarkedValues() {
+ return this.entries
+ .map((entry) => entry.markedKeys)
+ .reduce((a, b) => a.concat(b), []);
+ }
+
+ hasMark(key: string): boolean {
+ return this.entries.some((entry) => entry.hasMark(key));
+ }
+
+ toggleMark(key: string): void {
+ this.entries.forEach((entry) => entry.toggleMark(key));
}
}
diff --git a/sidebar.html b/sidebar/sidebar.html
similarity index 93%
rename from sidebar.html
rename to sidebar/sidebar.html
index ec8c448..c14104e 100644
--- a/sidebar.html
+++ b/sidebar/sidebar.html
@@ -39,6 +39,7 @@
-
+
+