diff --git a/.gitignore b/.gitignore
index 6ab38c8..26d5e85 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
.log
+node_modules
+sidebar.js
+/web-ext-artifacts/
diff --git a/email-template-harsh.js b/email-template-harsh.js
index 8096ac1..91c5097 100644
--- a/email-template-harsh.js
+++ b/email-template-harsh.js
@@ -8,7 +8,8 @@ function harsh_email_template() {
Informacje te są automatycznie wysyłane przez Państwa stronę przez
skrypty, które są na niej umieszczone. Pomimo faktu, że nie otrzymują
Państwo bezpośrednio i nie przechowują tych danych, w świetle RODO są
- Państwo administratorem moich danych osobowych (utwierdza taki stan rzeczy
+ Państwo współadministratorem moich danych osobowych (utwierdza taki stan
+ rzeczy
@@ -25,6 +26,34 @@ function harsh_email_template() {
występują, proszę o ich wskazanie,
dla każdego z celów i podmiotów z osobna .
+
+ Jeżeli wskazaną przez Państwa przesłanką legalizującą dany element procesu
+ przetwarzania danych osobowych przez Państwa stronę jest Art 6. pkt 1 lit.
+ a) RODO (zgoda), na mocy Art. 7 pkt 1 RODO proszę o wykazanie, że
+ udzieliłem Państwu zgodę na takie przetwarzanie moich danych osobowych
+ zanim to przetwarzanie nastąpiło, oraz że ta zgoda jest ważna w świetle
+ RODO (odnosząc się w szczególności do art. 7 ust. 3 RODO). Z góry
+ zaznaczam, że „ustawienia przeglądarki” nie stanowią ważnej w świetle RODO
+ zgody.
+
+
+ Jeżeli wskazaną przez Państwa przesłanką legalizującą dany element procesu
+ przetwarzania danych osobowych przez Państwa stronę jest Art 6. pkt 1 lit.
+ b) RODO (niezbędność takiego przetwarzania do wykonania umowy), proszę o
+ wskazanie, w jaki sposób ta konieczność zachodzi, oraz co sprawia, że
+ Państwa zdaniem nie można wykonać umowy związanej z wyświetleniem Państwa
+ strony bez przekazywania sztucznie nadanego ID w plikach Cookies lub
+ historii przeglądania w nagłówku Referer do wskazanych podmiotów trzecich.
+
+
+ Jeżeli wskazaną przez Państwa przesłanką legalizującą dany element procesu
+ przetwarzania danych osobowych przez Państwa stronę jest Art 6. pkt 1 lit.
+ f) RODO (uzasadniony interes), proszę o wskazanie, jaki to jest konkretny
+ interes, oraz o wynik testu równowagi pomiędzy Państwa interesem a moimi
+ podstawowymi wolnościami i prawami - ze wskazaniem tego, co sprawia, że w
+ Państwa ocenie Państwa uzasadniony interes przeważa moje prawa i interesy
+ w kontekście wspomnianych powyżej procesów przetwarzania danych.
+
Niniejszym zwracam się także z żądaniem wycofania przesłanych przez
Państwa stronę moich danych osobowych z baz wyżej wymienionych podmiotów
diff --git a/extended-request.ts b/extended-request.ts
new file mode 100644
index 0000000..cff37c9
--- /dev/null
+++ b/extended-request.ts
@@ -0,0 +1,60 @@
+import { getshorthost, Request } from "./util";
+
+export default class ExtendedRequest {
+ public tabId: number;
+ public url: string;
+ public requestHeaders: Request["requestHeaders"];
+
+ async getOrigin() {
+ let url: string;
+ if (this.data.tabId && this.data.tabId >= 0) {
+ const tab = await browser.tabs.get(this.data.tabId);
+ url = tab.url;
+ } else {
+ url = (this.data as any).frameAncestors[0].url;
+ }
+ return url;
+ }
+
+ async isThirdParty() {
+ const request_url = new URL(this.data.url);
+ const origin_url = new URL(await this.getOrigin());
+ if (request_url.host.includes(origin_url.host)) {
+ return false;
+ }
+ if (getshorthost(request_url.host) == getshorthost(origin_url.host)) {
+ return false;
+ }
+ return (
+ request_url.origin != origin_url.origin ||
+ (this.data as any).urlClassification.thirdParty.length > 0
+ );
+ }
+
+ getReferer() {
+ return this.data.requestHeaders.filter((h) => h.name === "Referer")[0]
+ .value;
+ }
+
+ async exposesOrigin() {
+ return this.getReferer().includes(new URL(await this.getOrigin()).host);
+ }
+
+ hasReferer() {
+ return this.data.requestHeaders.some((h) => h.name === "Referer");
+ }
+
+ hasCookie() {
+ return this.data.requestHeaders.some((h) => h.name === "Cookie");
+ }
+
+ getCookie() {
+ return this.requestHeaders.find((h) => h.name == "Cookie")?.value;
+ }
+
+ constructor(public data: Request) {
+ this.tabId = data.tabId;
+ this.url = data.url;
+ this.requestHeaders = data.requestHeaders;
+ }
+}
diff --git a/icons/border-48.png b/icons/border-48.png
new file mode 100644
index 0000000..90687de
Binary files /dev/null and b/icons/border-48.png differ
diff --git a/manifest.json b/manifest.json
index 03c3ff1..b54d864 100644
--- a/manifest.json
+++ b/manifest.json
@@ -5,18 +5,10 @@
"description": "Adds a red border to all webpages matching mozilla.org.",
- "icons": {
- "48": "icons/border-48.png"
- },
-
- "background": {
- "scripts": ["problematic.js"]
- },
-
- "browser_action": {
- "default_icon": "border-48.png",
- "default_title": "Pokaż problematyczne requesty",
- "default_popup": "popup.html"
+ "sidebar_action": {
+ "default_title": "ICD Skaner",
+ "default_panel": "sidebar.html",
+ "default_icon": "sidebar_icon.png"
},
"icons": {
"48": "icons/border-48.png"
@@ -27,5 +19,10 @@
"",
"webRequest",
"webRequestBlocking"
- ]
+ ],
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "problematic-requests@internet-czas-dzialac.pl"
+ }
+ }
}
diff --git a/memory.ts b/memory.ts
new file mode 100644
index 0000000..696d098
--- /dev/null
+++ b/memory.ts
@@ -0,0 +1,90 @@
+import ExtendedRequest from "./extended-request";
+import { getshorthost } from "./util";
+import { EventEmitter } from "events";
+
+export class RequestCluster extends EventEmitter {
+ public requests: ExtendedRequest[] = [];
+ constructor(public id: string) {
+ super();
+ }
+ add(request: ExtendedRequest) {
+ this.requests.push(request);
+ this.emit("change");
+ }
+
+ hasCookies() {
+ for (const request of this.requests) {
+ if (request.hasCookie()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ getCookiesContent(): string[] {
+ const cookieValues = new Set();
+ for (const request of this.requests) {
+ if (request.hasCookie()) {
+ cookieValues.add(request.getCookie());
+ }
+ }
+ return Array.from(cookieValues.values());
+ }
+
+ static sortCompare(a: RequestCluster, b: RequestCluster) {
+ if (a.hasCookies() == b.hasCookies()) {
+ if (a.id < b.id) {
+ return -1;
+ } else {
+ return 1;
+ }
+ } else {
+ if (a.hasCookies()) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ }
+}
+
+class Memory extends EventEmitter {
+ tab_to_history = {} as Record>;
+ async register(request: ExtendedRequest) {
+ if (
+ (await request.isThirdParty()) &&
+ request.hasReferer() &&
+ (await request.exposesOrigin())
+ ) {
+ if (!this.tab_to_history[request.tabId]) {
+ this.tab_to_history[request.tabId] = {};
+ }
+ const shorthost = getshorthost(new URL(request.url).host);
+ if (!this.tab_to_history[request.tabId][shorthost]) {
+ const cluster = new RequestCluster(shorthost);
+ this.tab_to_history[request.tabId][shorthost] = cluster;
+ }
+ this.tab_to_history[request.tabId][shorthost].add(request);
+ this.emit("change");
+ }
+ }
+
+ constructor() {
+ super();
+ browser.webRequest.onBeforeSendHeaders.addListener(
+ async (request) => {
+ this.register(new ExtendedRequest(request));
+ },
+ { urls: [""] },
+ ["requestHeaders"]
+ );
+ }
+
+ getClustersForTab(tab_id: number): Record {
+ return this.tab_to_history[tab_id] || {};
+ }
+}
+
+const memory = new Memory();
+
+export default memory;
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..da5d143
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,581 @@
+{
+ "name": "problematic-requests",
+ "version": "1.0.0",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "problematic-requests",
+ "version": "1.0.0",
+ "license": "ISC",
+ "dependencies": {
+ "esbuild": "^0.13.3",
+ "events": "^3.3.0",
+ "react": "^17.0.2",
+ "react-dom": "^17.0.2"
+ },
+ "devDependencies": {
+ "@types/events": "^3.0.0",
+ "@types/react-dom": "^17.0.9",
+ "web-ext-types": "^3.2.1"
+ }
+ },
+ "node_modules/@types/events": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz",
+ "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==",
+ "dev": true
+ },
+ "node_modules/@types/prop-types": {
+ "version": "15.7.4",
+ "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz",
+ "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==",
+ "dev": true
+ },
+ "node_modules/@types/react": {
+ "version": "17.0.26",
+ "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.26.tgz",
+ "integrity": "sha512-MXxuXrH2xOcv5cp/su4oz69dNQnSA90JjFw5HBd5wifw6Ihi94j7dRJm7qNsB30tnruXSCPc9qmlhGop4nh9Hw==",
+ "dev": true,
+ "dependencies": {
+ "@types/prop-types": "*",
+ "@types/scheduler": "*",
+ "csstype": "^3.0.2"
+ }
+ },
+ "node_modules/@types/react-dom": {
+ "version": "17.0.9",
+ "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.9.tgz",
+ "integrity": "sha512-wIvGxLfgpVDSAMH5utdL9Ngm5Owu0VsGmldro3ORLXV8CShrL8awVj06NuEXFQ5xyaYfdca7Sgbk/50Ri1GdPg==",
+ "dev": true,
+ "dependencies": {
+ "@types/react": "*"
+ }
+ },
+ "node_modules/@types/scheduler": {
+ "version": "0.16.2",
+ "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
+ "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==",
+ "dev": true
+ },
+ "node_modules/csstype": {
+ "version": "3.0.9",
+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.9.tgz",
+ "integrity": "sha512-rpw6JPxK6Rfg1zLOYCSwle2GFOOsnjmDYDaBwEcwoOg4qlsIVCN789VkBZDJAGi4T07gI4YSutR43t9Zz4Lzuw==",
+ "dev": true
+ },
+ "node_modules/esbuild": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.3.tgz",
+ "integrity": "sha512-98xovMLKnyhv3gcReUuAEi5Ig1rK6SIgvsJuBIcfwzqGSEHsV8UJjMlmkhHoHMf9XZybMpE9Zax8AA8f7i2hlQ==",
+ "hasInstallScript": true,
+ "bin": {
+ "esbuild": "bin/esbuild"
+ },
+ "optionalDependencies": {
+ "esbuild-android-arm64": "0.13.3",
+ "esbuild-darwin-64": "0.13.3",
+ "esbuild-darwin-arm64": "0.13.3",
+ "esbuild-freebsd-64": "0.13.3",
+ "esbuild-freebsd-arm64": "0.13.3",
+ "esbuild-linux-32": "0.13.3",
+ "esbuild-linux-64": "0.13.3",
+ "esbuild-linux-arm": "0.13.3",
+ "esbuild-linux-arm64": "0.13.3",
+ "esbuild-linux-mips64le": "0.13.3",
+ "esbuild-linux-ppc64le": "0.13.3",
+ "esbuild-openbsd-64": "0.13.3",
+ "esbuild-sunos-64": "0.13.3",
+ "esbuild-windows-32": "0.13.3",
+ "esbuild-windows-64": "0.13.3",
+ "esbuild-windows-arm64": "0.13.3"
+ }
+ },
+ "node_modules/esbuild-android-arm64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.13.3.tgz",
+ "integrity": "sha512-jc9E8vGTHkzb0Vwl74H8liANV9BWsqtzLHaKvcsRgf1M+aVCBSF0gUheduAKfDsbDMT0judeMLhwBP34EUesTA==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "android"
+ ]
+ },
+ "node_modules/esbuild-darwin-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.13.3.tgz",
+ "integrity": "sha512-8bG3Zq+ZNuLlIJebOO2+weI7P2LVf33sOzaUfHj8MuJ+1Ixe4KtQxfYp7qhFnP6xP2ToJaYHxGUfLeiUCEz9hw==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "darwin"
+ ]
+ },
+ "node_modules/esbuild-darwin-arm64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.3.tgz",
+ "integrity": "sha512-5E81eImYtTgh8pY7Gq4WQHhWkR/LvYadUXmuYeZBiP+3ADZJZcG60UFceZrjqNPaFOWKr/xmh4aNocwagEubcA==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "darwin"
+ ]
+ },
+ "node_modules/esbuild-freebsd-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.3.tgz",
+ "integrity": "sha512-ou+f91KkTGexi8HvF/BdtsITL6plbciQfZGys7QX6/QEwyE96PmL5KnU6ZQwoU7E99Ts6Sc9bUDq8HXJubKtBA==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "freebsd"
+ ]
+ },
+ "node_modules/esbuild-freebsd-arm64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.3.tgz",
+ "integrity": "sha512-F1zV7nySjHswJuvIgjkiG5liZ63MeazDGXGKViTCeegjZ71sAhOChcaGhKcu6vq9+vqZxlfEi1fmXlx6Pc3coQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "freebsd"
+ ]
+ },
+ "node_modules/esbuild-linux-32": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.13.3.tgz",
+ "integrity": "sha512-mHHc2v6uLrHH4zaaq5RB/5IWzgimEJ1HGldzf1qtGI513KZWfH0HRRQ8p1di4notJgBn7tDzWQ1f34ZHy69viQ==",
+ "cpu": [
+ "ia32"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/esbuild-linux-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.3.tgz",
+ "integrity": "sha512-FJ1De2O89mrOuqtaEXu41qIYJU6R41F+OA6vheNwcAQcX8fu0aiA13FJeLABq29BYJuTVgRj3cyC8q+tz19/dQ==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/esbuild-linux-arm": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.13.3.tgz",
+ "integrity": "sha512-9BJNRtLwBh3OP22cln9g3AJdbAQUcjRHqA4BScx9k4RZpGqPokFr548zpeplxWhcwrIjT8qPebwH9CrRVy8Bsw==",
+ "cpu": [
+ "arm"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/esbuild-linux-arm64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.3.tgz",
+ "integrity": "sha512-Cauhr45KSo+wRUojs+1qfycQqQCAXTOvsWvkZ6xmEMAXLAm+f8RQGDQeP8CAf8Yeelnegcn6UNdvzdzLHhWDFg==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/esbuild-linux-mips64le": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.3.tgz",
+ "integrity": "sha512-YVzJUGCncuuLm2boYyVeuMFsak4ZAhdiBwi0xNDZCC8sy+tS6Boe2mzcrD2uubv5JKAUOrpN186S1DtU4WgBgw==",
+ "cpu": [
+ "mips64el"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/esbuild-linux-ppc64le": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.3.tgz",
+ "integrity": "sha512-GU6CqqKtJEoyxC2QWHiJtmuOz9wc/jMv8ZloK2WwiGY5yMvAmM3PI103Dj7xcjebNTHBqITTUw/aigY1wx5A3w==",
+ "cpu": [
+ "ppc64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/esbuild-openbsd-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.3.tgz",
+ "integrity": "sha512-HVpkgpn4BQt4BPDAjTOpeMub6mzNWw6Y3gaLQJrpbO24pws6ZwYkY24OI3/Uo3LDCbH6856MM81JxECt92OWjA==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "openbsd"
+ ]
+ },
+ "node_modules/esbuild-sunos-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.13.3.tgz",
+ "integrity": "sha512-XncBVOtnEfUbPV4CaiFBxh38ychnBfwCxuTm9iAqcHzIwkmeNRN5qMzDyfE1jyfJje+Bbt6AvIfz6SdYt8/UEQ==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "sunos"
+ ]
+ },
+ "node_modules/esbuild-windows-32": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.13.3.tgz",
+ "integrity": "sha512-ZlgDz7d1nk8wQACi+z8IDzNZVUlN9iprAme+1YSTsfFDlkyI8jeaGWPk9EQFNY7rJzsLVYm6eZ2mhPioc7uT5A==",
+ "cpu": [
+ "ia32"
+ ],
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/esbuild-windows-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.13.3.tgz",
+ "integrity": "sha512-YX7KvRez3TR+GudlQm9tND/ssj2FsF9vb8ZWzAoZOLxpPzE3y+3SFJNrfDzzQKPzJ0Pnh9KBP4gsaMwJjKHDhw==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/esbuild-windows-arm64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.3.tgz",
+ "integrity": "sha512-nP7H0Y2a6OJd3Qi1Q8sehhyP4x4JoXK4S5y6FzH2vgaJgiyEurzFxjUufGdMaw+RxtxiwD/uRndUgwaZ2JD8lg==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/events": {
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
+ "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==",
+ "engines": {
+ "node": ">=0.8.x"
+ }
+ },
+ "node_modules/js-tokens": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
+ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
+ },
+ "node_modules/loose-envify": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
+ "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
+ "dependencies": {
+ "js-tokens": "^3.0.0 || ^4.0.0"
+ },
+ "bin": {
+ "loose-envify": "cli.js"
+ }
+ },
+ "node_modules/object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/react": {
+ "version": "17.0.2",
+ "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz",
+ "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==",
+ "dependencies": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/react-dom": {
+ "version": "17.0.2",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz",
+ "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==",
+ "dependencies": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1",
+ "scheduler": "^0.20.2"
+ },
+ "peerDependencies": {
+ "react": "17.0.2"
+ }
+ },
+ "node_modules/scheduler": {
+ "version": "0.20.2",
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz",
+ "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==",
+ "dependencies": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1"
+ }
+ },
+ "node_modules/web-ext-types": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/web-ext-types/-/web-ext-types-3.2.1.tgz",
+ "integrity": "sha512-oQZYDU3W8X867h8Jmt3129kRVKklz70db40Y6OzoTTuzOJpF/dB2KULJUf0txVPyUUXuyzV8GmT3nVvRHoG+Ew==",
+ "dev": true
+ }
+ },
+ "dependencies": {
+ "@types/events": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz",
+ "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==",
+ "dev": true
+ },
+ "@types/prop-types": {
+ "version": "15.7.4",
+ "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz",
+ "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==",
+ "dev": true
+ },
+ "@types/react": {
+ "version": "17.0.26",
+ "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.26.tgz",
+ "integrity": "sha512-MXxuXrH2xOcv5cp/su4oz69dNQnSA90JjFw5HBd5wifw6Ihi94j7dRJm7qNsB30tnruXSCPc9qmlhGop4nh9Hw==",
+ "dev": true,
+ "requires": {
+ "@types/prop-types": "*",
+ "@types/scheduler": "*",
+ "csstype": "^3.0.2"
+ }
+ },
+ "@types/react-dom": {
+ "version": "17.0.9",
+ "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.9.tgz",
+ "integrity": "sha512-wIvGxLfgpVDSAMH5utdL9Ngm5Owu0VsGmldro3ORLXV8CShrL8awVj06NuEXFQ5xyaYfdca7Sgbk/50Ri1GdPg==",
+ "dev": true,
+ "requires": {
+ "@types/react": "*"
+ }
+ },
+ "@types/scheduler": {
+ "version": "0.16.2",
+ "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
+ "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==",
+ "dev": true
+ },
+ "csstype": {
+ "version": "3.0.9",
+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.9.tgz",
+ "integrity": "sha512-rpw6JPxK6Rfg1zLOYCSwle2GFOOsnjmDYDaBwEcwoOg4qlsIVCN789VkBZDJAGi4T07gI4YSutR43t9Zz4Lzuw==",
+ "dev": true
+ },
+ "esbuild": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.3.tgz",
+ "integrity": "sha512-98xovMLKnyhv3gcReUuAEi5Ig1rK6SIgvsJuBIcfwzqGSEHsV8UJjMlmkhHoHMf9XZybMpE9Zax8AA8f7i2hlQ==",
+ "requires": {
+ "esbuild-android-arm64": "0.13.3",
+ "esbuild-darwin-64": "0.13.3",
+ "esbuild-darwin-arm64": "0.13.3",
+ "esbuild-freebsd-64": "0.13.3",
+ "esbuild-freebsd-arm64": "0.13.3",
+ "esbuild-linux-32": "0.13.3",
+ "esbuild-linux-64": "0.13.3",
+ "esbuild-linux-arm": "0.13.3",
+ "esbuild-linux-arm64": "0.13.3",
+ "esbuild-linux-mips64le": "0.13.3",
+ "esbuild-linux-ppc64le": "0.13.3",
+ "esbuild-openbsd-64": "0.13.3",
+ "esbuild-sunos-64": "0.13.3",
+ "esbuild-windows-32": "0.13.3",
+ "esbuild-windows-64": "0.13.3",
+ "esbuild-windows-arm64": "0.13.3"
+ }
+ },
+ "esbuild-android-arm64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.13.3.tgz",
+ "integrity": "sha512-jc9E8vGTHkzb0Vwl74H8liANV9BWsqtzLHaKvcsRgf1M+aVCBSF0gUheduAKfDsbDMT0judeMLhwBP34EUesTA==",
+ "optional": true
+ },
+ "esbuild-darwin-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.13.3.tgz",
+ "integrity": "sha512-8bG3Zq+ZNuLlIJebOO2+weI7P2LVf33sOzaUfHj8MuJ+1Ixe4KtQxfYp7qhFnP6xP2ToJaYHxGUfLeiUCEz9hw==",
+ "optional": true
+ },
+ "esbuild-darwin-arm64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.3.tgz",
+ "integrity": "sha512-5E81eImYtTgh8pY7Gq4WQHhWkR/LvYadUXmuYeZBiP+3ADZJZcG60UFceZrjqNPaFOWKr/xmh4aNocwagEubcA==",
+ "optional": true
+ },
+ "esbuild-freebsd-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.3.tgz",
+ "integrity": "sha512-ou+f91KkTGexi8HvF/BdtsITL6plbciQfZGys7QX6/QEwyE96PmL5KnU6ZQwoU7E99Ts6Sc9bUDq8HXJubKtBA==",
+ "optional": true
+ },
+ "esbuild-freebsd-arm64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.3.tgz",
+ "integrity": "sha512-F1zV7nySjHswJuvIgjkiG5liZ63MeazDGXGKViTCeegjZ71sAhOChcaGhKcu6vq9+vqZxlfEi1fmXlx6Pc3coQ==",
+ "optional": true
+ },
+ "esbuild-linux-32": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.13.3.tgz",
+ "integrity": "sha512-mHHc2v6uLrHH4zaaq5RB/5IWzgimEJ1HGldzf1qtGI513KZWfH0HRRQ8p1di4notJgBn7tDzWQ1f34ZHy69viQ==",
+ "optional": true
+ },
+ "esbuild-linux-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.3.tgz",
+ "integrity": "sha512-FJ1De2O89mrOuqtaEXu41qIYJU6R41F+OA6vheNwcAQcX8fu0aiA13FJeLABq29BYJuTVgRj3cyC8q+tz19/dQ==",
+ "optional": true
+ },
+ "esbuild-linux-arm": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.13.3.tgz",
+ "integrity": "sha512-9BJNRtLwBh3OP22cln9g3AJdbAQUcjRHqA4BScx9k4RZpGqPokFr548zpeplxWhcwrIjT8qPebwH9CrRVy8Bsw==",
+ "optional": true
+ },
+ "esbuild-linux-arm64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.3.tgz",
+ "integrity": "sha512-Cauhr45KSo+wRUojs+1qfycQqQCAXTOvsWvkZ6xmEMAXLAm+f8RQGDQeP8CAf8Yeelnegcn6UNdvzdzLHhWDFg==",
+ "optional": true
+ },
+ "esbuild-linux-mips64le": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.3.tgz",
+ "integrity": "sha512-YVzJUGCncuuLm2boYyVeuMFsak4ZAhdiBwi0xNDZCC8sy+tS6Boe2mzcrD2uubv5JKAUOrpN186S1DtU4WgBgw==",
+ "optional": true
+ },
+ "esbuild-linux-ppc64le": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.3.tgz",
+ "integrity": "sha512-GU6CqqKtJEoyxC2QWHiJtmuOz9wc/jMv8ZloK2WwiGY5yMvAmM3PI103Dj7xcjebNTHBqITTUw/aigY1wx5A3w==",
+ "optional": true
+ },
+ "esbuild-openbsd-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.3.tgz",
+ "integrity": "sha512-HVpkgpn4BQt4BPDAjTOpeMub6mzNWw6Y3gaLQJrpbO24pws6ZwYkY24OI3/Uo3LDCbH6856MM81JxECt92OWjA==",
+ "optional": true
+ },
+ "esbuild-sunos-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.13.3.tgz",
+ "integrity": "sha512-XncBVOtnEfUbPV4CaiFBxh38ychnBfwCxuTm9iAqcHzIwkmeNRN5qMzDyfE1jyfJje+Bbt6AvIfz6SdYt8/UEQ==",
+ "optional": true
+ },
+ "esbuild-windows-32": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.13.3.tgz",
+ "integrity": "sha512-ZlgDz7d1nk8wQACi+z8IDzNZVUlN9iprAme+1YSTsfFDlkyI8jeaGWPk9EQFNY7rJzsLVYm6eZ2mhPioc7uT5A==",
+ "optional": true
+ },
+ "esbuild-windows-64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.13.3.tgz",
+ "integrity": "sha512-YX7KvRez3TR+GudlQm9tND/ssj2FsF9vb8ZWzAoZOLxpPzE3y+3SFJNrfDzzQKPzJ0Pnh9KBP4gsaMwJjKHDhw==",
+ "optional": true
+ },
+ "esbuild-windows-arm64": {
+ "version": "0.13.3",
+ "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.3.tgz",
+ "integrity": "sha512-nP7H0Y2a6OJd3Qi1Q8sehhyP4x4JoXK4S5y6FzH2vgaJgiyEurzFxjUufGdMaw+RxtxiwD/uRndUgwaZ2JD8lg==",
+ "optional": true
+ },
+ "events": {
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
+ "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q=="
+ },
+ "js-tokens": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
+ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
+ },
+ "loose-envify": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
+ "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
+ "requires": {
+ "js-tokens": "^3.0.0 || ^4.0.0"
+ }
+ },
+ "object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
+ },
+ "react": {
+ "version": "17.0.2",
+ "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz",
+ "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==",
+ "requires": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1"
+ }
+ },
+ "react-dom": {
+ "version": "17.0.2",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz",
+ "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==",
+ "requires": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1",
+ "scheduler": "^0.20.2"
+ }
+ },
+ "scheduler": {
+ "version": "0.20.2",
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz",
+ "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==",
+ "requires": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1"
+ }
+ },
+ "web-ext-types": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/web-ext-types/-/web-ext-types-3.2.1.tgz",
+ "integrity": "sha512-oQZYDU3W8X867h8Jmt3129kRVKklz70db40Y6OzoTTuzOJpF/dB2KULJUf0txVPyUUXuyzV8GmT3nVvRHoG+Ew==",
+ "dev": true
+ }
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..995ec41
--- /dev/null
+++ b/package.json
@@ -0,0 +1,27 @@
+{
+ "name": "problematic-requests",
+ "version": "1.0.0",
+ "description": "",
+ "main": "email-template-harsh.js",
+ "scripts": {
+ "build": "npx esbuild sidebar.tsx --bundle --outfile=./lib/sidebar.js",
+ "watch": "npm run build -- --watch"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://git.kuba-orlik.name/kuba/problematic-requests.git"
+ },
+ "author": "",
+ "license": "ISC",
+ "dependencies": {
+ "esbuild": "^0.13.3",
+ "events": "^3.3.0",
+ "react": "^17.0.2",
+ "react-dom": "^17.0.2"
+ },
+ "devDependencies": {
+ "@types/events": "^3.0.0",
+ "@types/react-dom": "^17.0.9",
+ "web-ext-types": "^3.2.1"
+ }
+}
diff --git a/sidebar.html b/sidebar.html
new file mode 100644
index 0000000..bf9eb03
--- /dev/null
+++ b/sidebar.html
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sidebar.tsx b/sidebar.tsx
new file mode 100644
index 0000000..4f57d77
--- /dev/null
+++ b/sidebar.tsx
@@ -0,0 +1,150 @@
+import React, { useEffect, useState } from "react";
+import ReactDOM from "react-dom";
+import memory, { RequestCluster } from "./memory";
+import { parseCookie, Tab, useEmitter } from "./util";
+
+async function getTabByID(id: number) {
+ const tabs = await browser.tabs.query({ currentWindow: true });
+ return tabs.find((tab) => tab.id == id);
+}
+
+async function getCurrentTab() {
+ console.log("getCurrentTab");
+ const [tab] = await browser.tabs.query({
+ active: true,
+ windowId: browser.windows.WINDOW_ID_CURRENT,
+ });
+ return tab.id;
+}
+
+const TabDropdown = ({
+ setPickedTab,
+ pickedTab,
+}: {
+ setPickedTab: (tab_id: number) => void;
+ pickedTab: number;
+}) => {
+ const [tabs, setTabs] = useState([]);
+ useEffect(() => {
+ console.log("useEffect!");
+ browser.tabs.query({ currentWindow: true }).then(setTabs);
+ }, []);
+ return (
+ {
+ console.log(e.target.value);
+ setPickedTab(parseInt(e.target.value));
+ }}
+ >
+ {tabs.map((tab) => (
+
+ {tab.title}
+
+ ))}
+
+ );
+};
+
+const StolenDataRow = ({
+ tabID,
+ shorthost,
+ refreshToken,
+}: {
+ tabID: number;
+ shorthost: string;
+ refreshToken: number;
+}) => {
+ const cluster = memory.getClustersForTab(tabID)[shorthost];
+ console.log(
+ "!!",
+ cluster
+ .getCookiesContent()
+ .map(parseCookie)
+ .map((o) => Object.entries(o))
+ .reduce((a, b) => a.concat(b), [])
+ );
+ return (
+
+
+ {cluster.id} {cluster.hasCookies() ? "🍪" : ""} x
+ {cluster.requests.length}
+
+
+
+ {cluster
+ .getCookiesContent()
+ .map(parseCookie)
+ .map((o) => Object.entries(o))
+ .reduce((a, b) => a.concat(b), [])
+ .map(([cookie_name, cookie_value]) => (
+
+
+ {cookie_name}
+
+ {cookie_value}
+
+ ))}
+
+
+
+ );
+};
+
+const StolenData = ({
+ pickedTab,
+ refreshToken,
+}: {
+ pickedTab: number | null;
+ refreshToken: number;
+}) => {
+ const [tab, setTab] = useState(null);
+ useEffect(() => {
+ getTabByID(pickedTab).then(setTab);
+ }, [pickedTab]);
+ if (!pickedTab || !tab) {
+ return
;
+ }
+ const clusters = Object.values(memory.getClustersForTab(pickedTab)).sort(
+ RequestCluster.sortCompare
+ );
+ return (
+
+ {" "}
+
+
{tab.title}
+ {clusters.map((cluster) => (
+
+ ))}
+
+
+ );
+};
+
+const Sidebar = () => {
+ console.log("rendering!");
+ const [pickedTab, setPickedTab] = useState(null);
+ const counter = useEmitter(memory);
+ return (
+ <>
+
+
+ setPickedTab(await getCurrentTab())}
+ >
+ Wybierz aktywną kartę{" "}
+
+
+
+ >
+ );
+};
+
+ReactDOM.render( , document.getElementById("app"));
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..42cc230
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "compilerOptions": {
+ "jsx": "react",
+ "esModuleInterop": true,
+ "lib": ["es2017", "dom"],
+ "typeRoots": ["node_modules/@types", "node_modules/web-ext-types"],
+ "outDir": "lib"
+ }
+}
diff --git a/util.ts b/util.ts
new file mode 100644
index 0000000..754f51d
--- /dev/null
+++ b/util.ts
@@ -0,0 +1,44 @@
+import { EventEmitter } from "events";
+import { useEffect, useState } from "react";
+
+export type Unpromisify = T extends Promise ? R : T;
+export type Unarray = T extends Array ? R : T;
+
+export type Tab = Unarray>>;
+export type Request = Parameters<
+ Parameters[0]
+>[0];
+
+export function getshorthost(host: string) {
+ return host.split(".").slice(-2).join(".");
+}
+
+export function useEmitter(e: EventEmitter) {
+ const [counter, setCounter] = useState(0);
+ useEffect(() => {
+ console.log("useEmitter!");
+ const callback = () => {
+ console.log("Detected memory change!");
+ setCounter((counter) => counter + 1);
+ console.log("RT:", counter + 1);
+ };
+ e.on("change", callback);
+ return () => {
+ e.removeListener("change", callback);
+ };
+ }, []);
+ return counter;
+}
+
+export function parseCookie(cookie: string): Record {
+ return cookie
+ .split(";")
+ .map((l) => l.split("="))
+ .reduce(
+ (acc, [key, value]) => ({
+ ...acc,
+ [key]: value,
+ }),
+ {}
+ );
+}