import React, { Fragment } from 'react'; import ReactDOM from 'react-dom'; import { useEmitter } from '../../util'; import { getMemory } from '../../memory'; async function getCurrentTab() { const [tab] = await browser.tabs.query({ active: true, windowId: browser.windows.WINDOW_ID_CURRENT, }); return tab; } import './../../styles/global.scss'; import './toolbar.scss'; const Toolbar = () => { const [origin, setOrigin] = React.useState(null); const [eventCounts] = useEmitter(getMemory()); const [cookieDomainCopy, setCookieDomainCopy] = React.useState(null); const [_, setMarksOccurrence] = React.useState(false); const [exposedOriginDomainCopy, setExposedOriginDomainCopy] = React.useState( null ); const first_sentence_cookie = 'Strona dokonała zapisu i odczytu plików Cookie dla domen '; const first_sentence_history = 'Część informacji o Twojej historii przeglądania została wysłana do '; React.useEffect(() => { const listener = async () => { const tab = await getCurrentTab(); if (tab !== undefined && tab.url) { const url = new URL(tab.url); if (url.origin.startsWith('moz-extension')) { return; } setOrigin(url.origin); } else { console.warn('Out of the tab scope'); } }; browser.tabs.onUpdated.addListener(listener); listener(); return () => { browser.tabs.onUpdated.removeListener(listener); }; }); React.useEffect(() => { if (!origin) return; const exposedOriginDomains = Object.values(getMemory().getClustersForOrigin(origin)) .filter((cluster) => cluster.exposesOrigin()) .map((cluster) => cluster.id); setExposedOriginDomainCopy(''); switch (exposedOriginDomains.length) { case 0: break; case 1: setExposedOriginDomainCopy(`${exposedOriginDomains[0]}.`); break; case 2: setExposedOriginDomainCopy( `${exposedOriginDomains[0]} oraz ${exposedOriginDomains[1]}.` ); break; case 3: setExposedOriginDomainCopy( `${exposedOriginDomains[0]}, ${exposedOriginDomains[1]} oraz ${exposedOriginDomains[2]}.` ); break; default: setExposedOriginDomainCopy( `${exposedOriginDomains[0]}, ${exposedOriginDomains[1]} (i ${ exposedOriginDomains.length - 2 < 2 ? 2 : exposedOriginDomains.length - 2 } innych).` ); break; } }, [eventCounts['*'], origin]); React.useEffect(() => { if (!origin) return; const cookieDomains = Object.values(getMemory().getClustersForOrigin(origin)) .filter((cluster) => cluster.hasCookies()) .map((cluster) => cluster.id); setCookieDomainCopy(''); switch (cookieDomains.length) { case 0: break; case 1: setCookieDomainCopy(`${cookieDomains[0]}.`); break; case 2: setCookieDomainCopy(`${cookieDomains[0]} oraz ${cookieDomains[1]}.`); break; case 3: setCookieDomainCopy( `${cookieDomains[0]}, ${cookieDomains[1]} oraz ${cookieDomains[2]}.` ); break; default: setCookieDomainCopy( `${cookieDomains[0]}, ${cookieDomains[1]} (i ${ cookieDomains.length - 2 < 2 ? 2 : cookieDomains.length - 2 } innych).` ); break; } }, [eventCounts['*'], origin]); React.useEffect(() => { if (!origin) return; for (const cluster of Object.values(getMemory().getClustersForOrigin(origin))) { if (cluster.hasMarks()) { return setMarksOccurrence(true); } } return setMarksOccurrence(false); }, [eventCounts['*']]); function autoMark() { if (!origin) return; for (const cluster of Object.values(getMemory().getClustersForOrigin(origin))) { cluster.autoMark(); } return setMarksOccurrence(true); } return (
{origin ? ( <> Analiza strony {origin} ) : ( Przejdź do wybranej strony internetowej )}
{origin ? ( ) : null}
{origin ? ( {' '}
{ Object.values( getMemory().getClustersForOrigin(origin) ).filter((cluster) => cluster.hasCookies()).length }
{ Object.values( getMemory().getClustersForOrigin(origin) ).filter((cluster) => cluster.exposesOrigin()).length }
{Object.values(getMemory().getClustersForOrigin(origin)).length}
Liczba wykrytych domen podmiotów trzecich
{cookieDomainCopy ? (

cluster.hasCookies()) .map((domain) => domain.id) .join(', ')} > {first_sentence_cookie} {cookieDomainCopy}

) : null} {exposedOriginDomainCopy ? (

cluster.exposesOrigin()) .map((domain) => domain.id) .join(', ')} > {first_sentence_history} {exposedOriginDomainCopy}

) : null}
{exposedOriginDomainCopy || cookieDomainCopy ? (

Takie przetwarzanie danych może być niezgodne z prawem. Przejdź do analizy aby pomóc ustalić, czy ta strona nie narusza RODO.

) : (

Nie znaleziono problemów na tej stronie.

)}
) : null}
); }; ReactDOM.render(, document.getElementById('toolbar'));