2022-01-29 20:50:44 +01:00
|
|
|
|
import React from 'react';
|
2022-01-17 19:50:14 +01:00
|
|
|
|
import ReactDOM from 'react-dom';
|
2022-04-13 11:44:59 +02:00
|
|
|
|
import { useEmitter } from '../../util';
|
|
|
|
|
import { getMemory } from '../../memory';
|
2022-04-11 13:52:45 +02:00
|
|
|
|
browser.browserAction.setBadgeBackgroundColor({ color: '#ffb900' });
|
2021-10-03 09:03:56 +02:00
|
|
|
|
|
|
|
|
|
async function getCurrentTab() {
|
2022-01-17 19:50:14 +01:00
|
|
|
|
const [tab] = await browser.tabs.query({
|
|
|
|
|
active: true,
|
|
|
|
|
windowId: browser.windows.WINDOW_ID_CURRENT,
|
|
|
|
|
});
|
|
|
|
|
return tab;
|
2021-10-03 09:03:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-13 11:44:59 +02:00
|
|
|
|
import './../../styles/global.scss';
|
|
|
|
|
import './toolbar.scss';
|
2022-01-17 19:50:14 +01:00
|
|
|
|
|
2022-04-13 11:44:59 +02:00
|
|
|
|
const Toolbar = () => {
|
2022-01-29 21:20:25 +01:00
|
|
|
|
const [origin, setOrigin] = React.useState<string | null>(null);
|
|
|
|
|
const [minValueLength, setMinValueLength] = React.useState<number | null>(
|
|
|
|
|
localStorage.getItem('minValueLength') === null
|
|
|
|
|
? 7
|
|
|
|
|
: (localStorage.getItem('minValueLength') as unknown as number)
|
|
|
|
|
);
|
|
|
|
|
const [cookiesOnly, setCookiesOnly] = React.useState<boolean>(false);
|
|
|
|
|
const [stolenDataView, setStolenDataView] = React.useState<boolean>(true);
|
2022-02-02 10:33:09 +01:00
|
|
|
|
const [cookiesOrOriginOnly, setCookiesOrOriginOnly] = React.useState<boolean>(false);
|
2022-02-07 15:28:01 +01:00
|
|
|
|
const [eventCounts, setEventCounts] = useEmitter(getMemory());
|
2022-02-02 10:33:09 +01:00
|
|
|
|
const [marksOccurrence, setMarksOccurrence] = React.useState<boolean>(false);
|
|
|
|
|
const [warningDataDialogAck, setWarningDataDialogAck] = React.useState<boolean>(
|
|
|
|
|
localStorage.getItem('warningDataDialogAck') === null
|
|
|
|
|
? true
|
|
|
|
|
: localStorage.getItem('warningDataDialogAck') == 'true'
|
|
|
|
|
? true
|
|
|
|
|
: false
|
|
|
|
|
);
|
2022-01-29 21:20:25 +01:00
|
|
|
|
const [logoVisibility, setLogoVisibility] = React.useState<boolean>(
|
|
|
|
|
localStorage.getItem('logoVisibility') === null
|
|
|
|
|
? false
|
|
|
|
|
: localStorage.getItem('logoVisibility') == 'true'
|
|
|
|
|
? true
|
|
|
|
|
: false
|
|
|
|
|
);
|
2021-11-06 21:48:25 +01:00
|
|
|
|
|
2022-01-29 21:20:25 +01:00
|
|
|
|
React.useEffect(() => {
|
2022-02-07 15:28:01 +01:00
|
|
|
|
const listener = async () => {
|
2022-01-29 21:20:25 +01:00
|
|
|
|
console.log('tab change!');
|
|
|
|
|
const tab = await getCurrentTab();
|
|
|
|
|
const url = new URL(tab.url);
|
|
|
|
|
if (url.origin.startsWith('moz-extension')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setOrigin(url.origin);
|
|
|
|
|
};
|
2022-04-13 11:44:59 +02:00
|
|
|
|
|
2022-01-29 21:20:25 +01:00
|
|
|
|
browser.tabs.onUpdated.addListener(listener);
|
2022-04-11 14:31:27 +02:00
|
|
|
|
listener();
|
2022-01-29 21:20:25 +01:00
|
|
|
|
return () => {
|
|
|
|
|
browser.tabs.onUpdated.removeListener(listener);
|
|
|
|
|
};
|
|
|
|
|
});
|
2021-11-06 21:48:25 +01:00
|
|
|
|
|
2022-01-29 21:20:25 +01:00
|
|
|
|
React.useEffect(() => {
|
2022-02-02 10:33:09 +01:00
|
|
|
|
for (const cluster of Object.values(getMemory().getClustersForOrigin(origin))) {
|
2022-01-29 21:20:25 +01:00
|
|
|
|
if (cluster.hasMarks()) {
|
|
|
|
|
return setMarksOccurrence(true);
|
2022-01-19 14:12:52 +01:00
|
|
|
|
}
|
2022-01-29 21:20:25 +01:00
|
|
|
|
}
|
2022-04-11 13:52:45 +02:00
|
|
|
|
|
2022-01-29 21:20:25 +01:00
|
|
|
|
return setMarksOccurrence(false);
|
2022-02-07 15:28:01 +01:00
|
|
|
|
}, [eventCounts['*'], origin]);
|
2022-01-19 14:12:52 +01:00
|
|
|
|
|
2022-01-29 21:20:25 +01:00
|
|
|
|
return (
|
2022-04-13 11:44:59 +02:00
|
|
|
|
<div className="toolbar">
|
2022-04-13 13:57:31 +02:00
|
|
|
|
<header className="header">
|
|
|
|
|
<img src="../../assets/icon-addon.svg" height={32}></img>
|
2022-01-29 21:20:25 +01:00
|
|
|
|
<div
|
2022-01-24 12:50:54 +01:00
|
|
|
|
className={
|
|
|
|
|
logoVisibility
|
2022-01-29 21:20:25 +01:00
|
|
|
|
? 'webpage-metadata'
|
|
|
|
|
: 'webpage-metadata webpage-metadata--without-logo'
|
2022-01-24 12:50:54 +01:00
|
|
|
|
}
|
|
|
|
|
>
|
2022-01-29 21:20:25 +01:00
|
|
|
|
{origin ? (
|
|
|
|
|
<>
|
|
|
|
|
<span>Analiza strony</span>
|
2022-02-02 10:33:09 +01:00
|
|
|
|
<span className="webpage-metadata--hyperlink">{origin}</span>
|
2022-01-29 21:20:25 +01:00
|
|
|
|
</>
|
2022-01-29 21:16:53 +01:00
|
|
|
|
) : (
|
2022-01-29 21:20:25 +01:00
|
|
|
|
<span>Przejdź do wybranej strony internetowej</span>
|
2022-01-29 21:16:53 +01:00
|
|
|
|
)}
|
2022-01-29 21:20:25 +01:00
|
|
|
|
</div>
|
2022-01-17 19:50:14 +01:00
|
|
|
|
{stolenDataView ? (
|
2022-01-29 21:20:25 +01:00
|
|
|
|
<a href="https://internet-czas-dzialac.pl">
|
2022-02-02 10:33:09 +01:00
|
|
|
|
<img src="/assets/icons/info_circle_outline.svg" width="20" height="20" />
|
2022-01-29 21:20:25 +01:00
|
|
|
|
</a>
|
|
|
|
|
) : (
|
|
|
|
|
<button onClick={() => setStolenDataView(true)}>
|
2022-02-02 10:33:09 +01:00
|
|
|
|
<img src="/assets/icons/short_left.svg" width="20" height="20" />
|
2022-01-29 21:20:25 +01:00
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</header>
|
2022-01-29 21:16:53 +01:00
|
|
|
|
|
2022-04-13 13:57:31 +02:00
|
|
|
|
<section className="summary">
|
|
|
|
|
<div>
|
|
|
|
|
<div className="counters">
|
|
|
|
|
<div className="counter counter--browser-history">12</div>
|
|
|
|
|
<div className="counter counter--cookies">21</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="big-counter">33</div>
|
|
|
|
|
</div>
|
|
|
|
|
<p>Liczba wykrytych domen podmiotów trzecich</p>
|
|
|
|
|
</section>
|
2022-02-02 10:33:09 +01:00
|
|
|
|
|
2022-04-13 13:57:31 +02:00
|
|
|
|
<section className="details">
|
|
|
|
|
<p>
|
|
|
|
|
Strona wp.pl wysłała informacje o części Twojej historii przeglądania do
|
|
|
|
|
facebook.com, adnsx.com (i 43 innych).
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
Dokonała też zapisu i odczytu plików Cookie dla domen doubleclick.google.net,
|
|
|
|
|
3dsio.com (i 59 innych).
|
|
|
|
|
</p>
|
|
|
|
|
</section>
|
2022-01-29 21:20:25 +01:00
|
|
|
|
|
2022-04-13 13:57:31 +02:00
|
|
|
|
<section className="warning-container">
|
|
|
|
|
<span>
|
|
|
|
|
<strong>Takie przetwarzanie danych może być niezgodne z prawem.</strong> Kliknij
|
|
|
|
|
w przycisk <i>Generuj raport</i>, aby pomóc ustalić, czy ta strona nie narusza
|
|
|
|
|
RODO.
|
|
|
|
|
</span>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section className="actions">
|
|
|
|
|
<a href="">Pokaż szczegóły</a>
|
|
|
|
|
<button>Generuj raport</button>
|
2022-01-29 21:20:25 +01:00
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2021-10-03 09:03:56 +02:00
|
|
|
|
};
|
2022-01-29 21:20:25 +01:00
|
|
|
|
|
2022-04-13 11:44:59 +02:00
|
|
|
|
ReactDOM.render(<Toolbar />, document.getElementById('toolbar'));
|