From d220c22291e4106bd6d9f3ef5d343e1e33b48cae Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sat, 6 Nov 2021 20:02:02 +0100 Subject: [PATCH] Add functioning cookiesOnly filter --- manifest.json | 4 ++- request-cluster.ts | 8 ++++-- sidebar.tsx | 69 +++++++++++++++++++++++++++++++--------------- 3 files changed, 56 insertions(+), 25 deletions(-) diff --git a/manifest.json b/manifest.json index b54d864..c1220db 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,9 @@ "storage", "", "webRequest", - "webRequestBlocking" + "webRequestBlocking", + "cookies", + "privacy" ], "browser_specific_settings": { "gecko": { diff --git a/request-cluster.ts b/request-cluster.ts index 50623ba..5ef4a2d 100644 --- a/request-cluster.ts +++ b/request-cluster.ts @@ -17,7 +17,7 @@ export class StolenDataEntry { ) { try { this.iab = TCString.decode(value); - console.log(this.iab); + // console.log(this.iab); this.isIAB = true; } catch (e) {} } @@ -52,13 +52,17 @@ export class RequestCluster extends EventEmitter { return false; } - getStolenData(filter: { minValueLength: number }): StolenDataEntry[] { + getStolenData(filter: { + minValueLength: number; + cookiesOnly: boolean; + }): StolenDataEntry[] { return this.requests .map((request) => request.getAllStolenData()) .reduce((a, b) => a.concat(b), []) .filter((entry) => { return entry.value.length >= filter.minValueLength; }) + .filter((entry) => !filter.cookiesOnly || entry.source === "cookie") .sort((entry1, entry2) => entry1.getPriority() > entry2.getPriority() ? -1 : 1 ) diff --git a/sidebar.tsx b/sidebar.tsx index 763e184..e72fe98 100644 --- a/sidebar.tsx +++ b/sidebar.tsx @@ -48,13 +48,14 @@ const TabDropdown = ({ const StolenDataRow = ({ tabID, shorthost, - refreshToken, minValueLength, + cookiesOnly, }: { tabID: number; shorthost: string; refreshToken: number; minValueLength: number; + cookiesOnly: boolean; }) => { const cluster = memory.getClustersForTab(tabID)[shorthost]; const icons: Record = { @@ -71,17 +72,19 @@ const StolenDataRow = ({ - {cluster.getStolenData({ minValueLength }).map((entry) => ( - - - - - - ))} + {cluster + .getStolenData({ minValueLength, cookiesOnly }) + .map((entry) => ( + + + + + + ))}
- {entry.name} - {icons[entry.source]} - {entry.value} {entry.isIAB ? "!!!!! IAB" : ""} -
+ {entry.name} + {icons[entry.source]} + {entry.value} {entry.isIAB ? "!!!!! IAB" : ""} +
@@ -92,10 +95,12 @@ const StolenData = ({ pickedTab, refreshToken, minValueLength, + cookiesOnly, }: { pickedTab: number | null; refreshToken: number; minValueLength: number; + cookiesOnly: boolean; }) => { const [tab, setTab] = useState(null); useEffect(() => { @@ -114,21 +119,29 @@ const StolenData = ({

{tab.title}

- {clusters.map((cluster) => ( - - ))} + {clusters + .filter((cluster) => !cookiesOnly || cluster.hasCookies()) + .map((cluster) => ( + + ))} ); }; -const Options = ({ minValueLength, setMinValueLength }) => { +const Options = ({ + minValueLength, + setMinValueLength, + cookiesOnly, + setCookiesOnly, +}) => { return (

Zaawansowane ustawienia

@@ -141,6 +154,14 @@ const Options = ({ minValueLength, setMinValueLength }) => { value={minValueLength} onChange={(e) => setMinValueLength(parseInt(e.target.value))} /> +
+ setCookiesOnly(e.target.checked)} + /> +
); }; @@ -148,6 +169,7 @@ const Options = ({ minValueLength, setMinValueLength }) => { const Sidebar = () => { const [pickedTab, setPickedTab] = useState(null); const [minValueLength, setMinValueLength] = useState(7); + const [cookiesOnly, setCookiesOnly] = useState(false); const counter = useEmitter(memory); return ( <> @@ -163,11 +185,14 @@ const Sidebar = () => { );