Working sidebar

This commit is contained in:
Kuba Orlik 2021-10-03 09:03:56 +02:00
parent bb86842c92
commit 9441ddd98e
12 changed files with 1044 additions and 14 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
.log
node_modules
sidebar.js
/web-ext-artifacts/

View File

@ -8,7 +8,8 @@ function harsh_email_template() {
Informacje te automatycznie wysyłane przez Państwa stronę przez
skrypty, które na niej umieszczone. Pomimo faktu, że nie otrzymują
Państwo bezpośrednio i nie przechowują tych danych, w świetle RODO
Państwo administratorem moich danych osobowych (utwierdza taki stan rzeczy
Państwo współadministratorem moich danych osobowych (utwierdza taki stan
rzeczy
<a
href="https://curia.europa.eu/juris/document/document.jsf?text=&docid=216555&pageIndex=0&doclang=PL&mode=lst&dir=&occ=first&part=1&cid=3313819"
>
@ -25,6 +26,34 @@ function harsh_email_template() {
występują, proszę o ich wskazanie,
<strong> dla każdego z celów i podmiotów z osobna</strong>.
</p>
<p>
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.
</p>
<p>
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.
</p>
<p>
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.
</p>
<p>
Niniejszym zwracam się także z żądaniem wycofania przesłanych przez
Państwa stronę moich danych osobowych z baz wyżej wymienionych podmiotów

60
extended-request.ts Normal file
View File

@ -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;
}
}

BIN
icons/border-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

View File

@ -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 @@
"<all_urls>",
"webRequest",
"webRequestBlocking"
]
],
"browser_specific_settings": {
"gecko": {
"id": "problematic-requests@internet-czas-dzialac.pl"
}
}
}

90
memory.ts Normal file
View File

@ -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<string>();
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<string, Record<string, RequestCluster>>;
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: ["<all_urls>"] },
["requestHeaders"]
);
}
getClustersForTab(tab_id: number): Record<string, RequestCluster> {
return this.tab_to_history[tab_id] || {};
}
}
const memory = new Memory();
export default memory;

581
package-lock.json generated Normal file
View File

@ -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
}
}
}

27
package.json Normal file
View File

@ -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"
}
}

40
sidebar.html Normal file
View File

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
button {
display: inline-block;
line-height: 3rem;
padding: 0 1rem;
white-space: nowrap;
}
select {
height: 3rem;
line-height: 3rem;
flex-shrink: 1;
}
#tab_dropdown {
flex-basis: 20px;
width: 100px !important;
flex-grow: 1;
}
#selector {
display: flex;
flex-flow: row nowrap;
align-items: center;
}
#app {
user-select: text;
}
</style>
</head>
<body>
<div id="app"></div>
<script src="./lib/sidebar.js"></script>
</body>
</html>

150
sidebar.tsx Normal file
View File

@ -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 (
<select
id="tab_dropdown"
value={pickedTab}
onChange={async (e) => {
console.log(e.target.value);
setPickedTab(parseInt(e.target.value));
}}
>
{tabs.map((tab) => (
<option value={tab.id} key={tab.id}>
{tab.title}
</option>
))}
</select>
);
};
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 (
<div>
<h2>
{cluster.id} {cluster.hasCookies() ? "🍪" : ""} x
{cluster.requests.length}
</h2>
<table>
<tbody>
{cluster
.getCookiesContent()
.map(parseCookie)
.map((o) => Object.entries(o))
.reduce((a, b) => a.concat(b), [])
.map(([cookie_name, cookie_value]) => (
<tr>
<th style={{ maxWidth: "200px", wordWrap: "break-word" }}>
{cookie_name}
</th>
<td>{cookie_value}</td>
</tr>
))}
</tbody>
</table>
</div>
);
};
const StolenData = ({
pickedTab,
refreshToken,
}: {
pickedTab: number | null;
refreshToken: number;
}) => {
const [tab, setTab] = useState<Tab | null>(null);
useEffect(() => {
getTabByID(pickedTab).then(setTab);
}, [pickedTab]);
if (!pickedTab || !tab) {
return <div></div>;
}
const clusters = Object.values(memory.getClustersForTab(pickedTab)).sort(
RequestCluster.sortCompare
);
return (
<div style={{ padding: "5px" }}>
{" "}
<div>
<img src={tab.favIconUrl} width="20" height="20" /> {tab.title}
{clusters.map((cluster) => (
<StolenDataRow
tabID={pickedTab}
shorthost={cluster.id}
key={cluster.id}
refreshToken={refreshToken}
/>
))}
</div>
</div>
);
};
const Sidebar = () => {
console.log("rendering!");
const [pickedTab, setPickedTab] = useState<number | null>(null);
const counter = useEmitter(memory);
return (
<>
<div id="selector">
<TabDropdown setPickedTab={setPickedTab} pickedTab={pickedTab} />
<button
id="get_current_tab_button"
onClick={async () => setPickedTab(await getCurrentTab())}
>
Wybierz aktywną kartę{" "}
</button>
</div>
<StolenData pickedTab={pickedTab} refreshToken={counter} />
</>
);
};
ReactDOM.render(<Sidebar />, document.getElementById("app"));

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"jsx": "react",
"esModuleInterop": true,
"lib": ["es2017", "dom"],
"typeRoots": ["node_modules/@types", "node_modules/web-ext-types"],
"outDir": "lib"
}
}

44
util.ts Normal file
View File

@ -0,0 +1,44 @@
import { EventEmitter } from "events";
import { useEffect, useState } from "react";
export type Unpromisify<T> = T extends Promise<infer R> ? R : T;
export type Unarray<T> = T extends Array<infer R> ? R : T;
export type Tab = Unarray<Unpromisify<ReturnType<typeof browser.tabs.query>>>;
export type Request = Parameters<
Parameters<typeof browser.webRequest.onBeforeSendHeaders.addListener>[0]
>[0];
export function getshorthost(host: string) {
return host.split(".").slice(-2).join(".");
}
export function useEmitter(e: EventEmitter) {
const [counter, setCounter] = useState<number>(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<string, string> {
return cookie
.split(";")
.map((l) => l.split("="))
.reduce(
(acc, [key, value]) => ({
...acc,
[key]: value,
}),
{}
);
}