import React, { useEffect, useState } from "react"; import ReactDOM from "react-dom"; import memory from "./memory"; import { RequestCluster, Sources } from "./request-cluster"; import { getshorthost, useEmitter } from "./util"; async function getCurrentTab() { const [tab] = await browser.tabs.query({ active: true, windowId: browser.windows.WINDOW_ID_CURRENT, }); return tab; } const TabDropdown = ({ setPickedTab, pickedTab, }: { setPickedTab: (tab_id: number) => void; pickedTab: number; }) => { const [tabs, setTabs] = useState([]); useEffect(() => { browser.tabs.query({ currentWindow: true }).then(setTabs); }, []); return ( ); }; const StolenDataRow = ({ origin, shorthost, minValueLength, cookiesOnly, }: { origin: string; shorthost: string; refreshToken: number; minValueLength: number; cookiesOnly: boolean; }) => { const cluster = memory.getClustersForOrigin(origin)[shorthost]; const icons: Record = { cookie: "🍪", pathname: "🛣", queryparams: "🅿", header: "H", }; return (

{cluster.id} {cluster.hasCookies() ? "🍪" : ""} x {cluster.requests.length}{" "} cluster.removeAllCookies()} > Wyczyść cookiesy

{cluster .getStolenData({ minValueLength, cookiesOnly }) .map((entry) => ( ))}
{entry.name} {icons[entry.source]} {entry.value} {entry.isIAB ? "!!!!! IAB" : ""}
); }; const StolenData = ({ origin, minValueLength, refreshToken, cookiesOnly, }: { origin: string; refreshToken: number; minValueLength: number; cookiesOnly: boolean; }) => { if (!origin) { return
; } const clusters = Object.values(memory.getClustersForOrigin(origin)).sort( RequestCluster.sortCompare ); return (
{" "}

{origin}

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

Zaawansowane ustawienia

setMinValueLength(parseInt(e.target.value))} />
setCookiesOnly(e.target.checked)} />
); }; const Sidebar = () => { const [origin, setOrigin] = useState(null); const [minValueLength, setMinValueLength] = useState(7); const [cookiesOnly, setCookiesOnly] = useState(false); const counter = useEmitter(memory); useEffect(() => { const listener = async (data) => { console.log("tab change!"); const tab = await getCurrentTab(); const url = new URL(tab.url); console.log( "NEW ORIGIN", url.origin, url.origin.startsWith("moz-extension") ); if (url.origin.startsWith("moz-extension")) { return; } setOrigin(url.origin); }; browser.tabs.onUpdated.addListener(listener); return () => { browser.tabs.onUpdated.removeListener(listener); }; }); return ( <> {/*
*/} ); }; ReactDOM.render(, document.getElementById("app"));