2022-01-17 19:50:14 +01:00
|
|
|
|
import React, { Fragment, useEffect, useState } from 'react';
|
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
|
import Options from '../options';
|
|
|
|
|
import { StolenData } from './stolen-data';
|
2022-01-19 13:12:28 +01:00
|
|
|
|
import { getshorthost, useEmitter } from '../util';
|
2022-01-17 19:50:14 +01:00
|
|
|
|
import { getMemory } from '../memory';
|
2022-01-19 13:12:28 +01:00
|
|
|
|
import InfoCircleIcon from '../assets/icons/info_circle_outline.svg';
|
|
|
|
|
import SettingsIcon from '../assets/icons/settings.svg';
|
|
|
|
|
import TrashIcon from '../assets/icons/trash_full.svg';
|
|
|
|
|
import MailIcon from '../assets/icons/mail.svg';
|
|
|
|
|
import ShortLeftIcon from '../assets/icons/short_left.svg';
|
2022-01-23 21:42:49 +01:00
|
|
|
|
import CloseBigIcon from '../assets/icons/close_big.svg';
|
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-01-17 19:50:14 +01:00
|
|
|
|
import './global.scss';
|
|
|
|
|
import './sidebar.scss';
|
|
|
|
|
|
2021-10-03 09:03:56 +02:00
|
|
|
|
const Sidebar = () => {
|
2022-01-17 19:50:14 +01:00
|
|
|
|
const [origin, setOrigin] = useState<string | null>(null);
|
|
|
|
|
const [minValueLength, setMinValueLength] = useState<number | null>(7);
|
|
|
|
|
const [cookiesOnly, setCookiesOnly] = useState<boolean>(false);
|
|
|
|
|
const [stolenDataView, setStolenDataView] = useState<boolean>(true);
|
|
|
|
|
const [cookiesOrOriginOnly, setCookiesOrOriginOnly] =
|
|
|
|
|
useState<boolean>(false);
|
|
|
|
|
const [counter, setCounter] = useEmitter(getMemory());
|
2022-01-19 14:12:52 +01:00
|
|
|
|
const [marksOccurrence, setMarksOccurrence] = useState<boolean>(false);
|
2022-01-24 12:50:54 +01:00
|
|
|
|
const [warningDataDialogAck, setWarningDataDialogAck] = useState<boolean>(
|
|
|
|
|
localStorage.getItem('warningDataDialogAck') === null
|
|
|
|
|
? true
|
|
|
|
|
: localStorage.getItem('warningDataDialogAck') == 'true'
|
|
|
|
|
? true
|
|
|
|
|
: false
|
|
|
|
|
);
|
|
|
|
|
const [logoVisibility, setLogoVisibility] = useState<boolean>(
|
|
|
|
|
localStorage.getItem('logoVisibility') === null
|
|
|
|
|
? true
|
|
|
|
|
: localStorage.getItem('logoVisibility') == 'true'
|
|
|
|
|
? true
|
|
|
|
|
: false
|
2022-01-24 12:21:28 +01:00
|
|
|
|
);
|
2021-11-06 21:48:25 +01:00
|
|
|
|
|
2022-01-17 19:50:14 +01:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
const listener = async (data: any) => {
|
|
|
|
|
console.log('tab change!');
|
|
|
|
|
const tab = await getCurrentTab();
|
|
|
|
|
const url = new URL(tab.url);
|
|
|
|
|
if (url.origin.startsWith('moz-extension')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setOrigin(url.origin);
|
|
|
|
|
};
|
|
|
|
|
browser.tabs.onUpdated.addListener(listener);
|
|
|
|
|
return () => {
|
|
|
|
|
browser.tabs.onUpdated.removeListener(listener);
|
|
|
|
|
};
|
|
|
|
|
});
|
2021-11-06 21:48:25 +01:00
|
|
|
|
|
2022-01-19 14:12:52 +01:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
for (const cluster of Object.values(
|
|
|
|
|
getMemory().getClustersForOrigin(origin)
|
|
|
|
|
)) {
|
|
|
|
|
if (cluster.hasMarks()) {
|
|
|
|
|
return setMarksOccurrence(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return setMarksOccurrence(false);
|
2022-01-19 14:17:13 +01:00
|
|
|
|
}, [counter, origin]);
|
2022-01-19 14:12:52 +01:00
|
|
|
|
|
2022-01-17 19:50:14 +01:00
|
|
|
|
return (
|
2022-01-20 19:03:03 +01:00
|
|
|
|
<div className="sidebar">
|
2022-01-17 19:50:14 +01:00
|
|
|
|
{/* <div id="selector">
|
2021-10-03 09:03:56 +02:00
|
|
|
|
<TabDropdown setPickedTab={setPickedTab} pickedTab={pickedTab} />
|
|
|
|
|
<button
|
|
|
|
|
id="get_current_tab_button"
|
|
|
|
|
onClick={async () => setPickedTab(await getCurrentTab())}
|
|
|
|
|
>
|
|
|
|
|
Wybierz aktywną kartę{" "}
|
|
|
|
|
</button>
|
2021-11-06 21:48:25 +01:00
|
|
|
|
</div> */}
|
2022-01-24 12:50:54 +01:00
|
|
|
|
<header
|
|
|
|
|
className={
|
|
|
|
|
logoVisibility ? 'header' : 'header header--without-logo'
|
|
|
|
|
}
|
|
|
|
|
>
|
2022-01-17 19:50:14 +01:00
|
|
|
|
<img
|
|
|
|
|
src="../assets/logo-internet-czas-dzialac.svg"
|
2022-01-24 12:21:28 +01:00
|
|
|
|
height={40}
|
2022-01-24 12:50:54 +01:00
|
|
|
|
style={!logoVisibility ? { display: 'none' } : null}
|
2022-01-17 19:50:14 +01:00
|
|
|
|
></img>
|
2022-01-24 12:50:54 +01:00
|
|
|
|
<div
|
|
|
|
|
className={
|
|
|
|
|
logoVisibility
|
|
|
|
|
? 'webpage-metadata'
|
|
|
|
|
: 'webpage-metadata webpage-metadata--without-logo'
|
|
|
|
|
}
|
|
|
|
|
>
|
2022-01-24 12:21:28 +01:00
|
|
|
|
{origin ? (
|
|
|
|
|
<Fragment>
|
|
|
|
|
<span>Analiza strony</span>
|
|
|
|
|
<span className="webpage-metadata--hyperlink">
|
|
|
|
|
{origin}
|
|
|
|
|
</span>
|
|
|
|
|
</Fragment>
|
|
|
|
|
) : (
|
|
|
|
|
<span>Przejdź do wybranej strony internetowej</span>
|
|
|
|
|
)}
|
2022-01-17 19:50:14 +01:00
|
|
|
|
</div>
|
2022-01-19 13:12:28 +01:00
|
|
|
|
{stolenDataView ? (
|
|
|
|
|
<a href="https://internet-czas-dzialac.pl">
|
|
|
|
|
<InfoCircleIcon />
|
|
|
|
|
</a>
|
|
|
|
|
) : (
|
|
|
|
|
<button onClick={() => setStolenDataView(true)}>
|
|
|
|
|
<ShortLeftIcon />
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
2022-01-17 19:50:14 +01:00
|
|
|
|
</header>
|
|
|
|
|
|
2022-01-23 21:42:49 +01:00
|
|
|
|
{stolenDataView ? (
|
|
|
|
|
<nav>
|
|
|
|
|
<button onClick={() => setStolenDataView(!stolenDataView)}>
|
|
|
|
|
{/* {stolenDataView ? 'Options' : 'Data'}
|
|
|
|
|
*/}
|
|
|
|
|
<SettingsIcon width={20} height={20} />
|
|
|
|
|
<span>Ustawienia wtyczki</span>
|
|
|
|
|
</button>
|
|
|
|
|
{/* <button
|
2022-01-19 13:12:28 +01:00
|
|
|
|
onClick={() => {
|
|
|
|
|
getMemory().removeCookiesFor(
|
|
|
|
|
origin,
|
|
|
|
|
getshorthost(new URL(origin).host)
|
|
|
|
|
);
|
2022-01-19 14:12:52 +01:00
|
|
|
|
setMarksOccurrence(false);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<TrashIcon />
|
|
|
|
|
<span>Wyczyść ciasteczka first-party</span>
|
2022-01-19 14:17:13 +01:00
|
|
|
|
</button> */}
|
2022-01-23 21:42:49 +01:00
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
getMemory().removeRequestsFor(origin);
|
|
|
|
|
setCounter((c) => c + 1);
|
|
|
|
|
setMarksOccurrence(false);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{/* {stolenDataView ? 'Options' : 'Data'}
|
|
|
|
|
*/}
|
|
|
|
|
<TrashIcon width={20} height={20} />
|
|
|
|
|
<span>Wyczyść ciasteczka</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
disabled={!marksOccurrence}
|
|
|
|
|
title={
|
|
|
|
|
marksOccurrence
|
|
|
|
|
? 'Kliknij, aby wygenerować wiadomość'
|
|
|
|
|
: 'Zaznacz poniżej elementy, aby móc wygenerować wiadomość'
|
|
|
|
|
}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
const params = [
|
|
|
|
|
'height=' + screen.height,
|
|
|
|
|
'width=' + screen.width,
|
|
|
|
|
'fullscreen=yes',
|
|
|
|
|
].join(',');
|
|
|
|
|
window.open(
|
|
|
|
|
`/report-window/report-window.html?origin=${origin}`,
|
|
|
|
|
'new_window',
|
|
|
|
|
params
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<MailIcon width={20} height={20} />
|
|
|
|
|
<span>
|
|
|
|
|
Utwórz wiadomość dla administratora tej witryny
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
</nav>
|
|
|
|
|
) : null}
|
2022-01-17 19:50:14 +01:00
|
|
|
|
|
|
|
|
|
<section>
|
|
|
|
|
{stolenDataView ? (
|
2022-01-23 21:42:49 +01:00
|
|
|
|
<Fragment>
|
2022-01-24 12:50:54 +01:00
|
|
|
|
{warningDataDialogAck ? (
|
2022-01-23 21:42:49 +01:00
|
|
|
|
<section className="warning-container">
|
|
|
|
|
<span>
|
|
|
|
|
<strong>Uwaga!</strong> Niekoniecznie każda
|
|
|
|
|
przechwycona poniżej informacja jest daną
|
|
|
|
|
osobową. Niektóre z podanych domen mogą
|
|
|
|
|
należeć do właściciela strony i nie
|
|
|
|
|
reprezentować podmiotów trzecich.
|
|
|
|
|
</span>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
2022-01-24 12:50:54 +01:00
|
|
|
|
setWarningDataDialogAck(false);
|
2022-01-23 21:42:49 +01:00
|
|
|
|
localStorage.setItem(
|
2022-01-24 12:50:54 +01:00
|
|
|
|
'warningDataDialogAck',
|
|
|
|
|
false as unknown as string
|
2022-01-23 21:42:49 +01:00
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<CloseBigIcon width={16} height={16} />
|
|
|
|
|
</button>
|
|
|
|
|
</section>
|
|
|
|
|
) : null}
|
|
|
|
|
<StolenData
|
|
|
|
|
origin={origin}
|
|
|
|
|
refreshToken={counter}
|
|
|
|
|
refresh={() => setCounter((c) => c + 1)}
|
|
|
|
|
minValueLength={minValueLength}
|
|
|
|
|
cookiesOnly={cookiesOnly}
|
|
|
|
|
cookiesOrOriginOnly={cookiesOrOriginOnly}
|
|
|
|
|
/>
|
|
|
|
|
</Fragment>
|
2022-01-17 19:50:14 +01:00
|
|
|
|
) : (
|
|
|
|
|
<Options
|
|
|
|
|
minValueLength={minValueLength}
|
|
|
|
|
setMinValueLength={setMinValueLength}
|
|
|
|
|
cookiesOnly={cookiesOnly}
|
|
|
|
|
setCookiesOnly={setCookiesOnly}
|
|
|
|
|
cookiesOrOriginOnly={cookiesOrOriginOnly}
|
|
|
|
|
setCookiesOrOriginOnly={setCookiesOrOriginOnly}
|
2022-01-24 12:50:54 +01:00
|
|
|
|
warningDataDialogAck={warningDataDialogAck}
|
|
|
|
|
setWarningDataDialogAck={setWarningDataDialogAck}
|
2022-01-24 12:21:28 +01:00
|
|
|
|
logoVisibility={logoVisibility}
|
|
|
|
|
setLogoVisibility={setLogoVisibility}
|
2022-01-17 19:50:14 +01:00
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</section>
|
|
|
|
|
|
2022-01-19 14:23:44 +01:00
|
|
|
|
{/* <footer>Footer marks → {JSON.stringify(marksOccurrence)}</footer> */}
|
2022-01-20 19:03:03 +01:00
|
|
|
|
</div>
|
2022-01-17 19:50:14 +01:00
|
|
|
|
);
|
2021-10-03 09:03:56 +02:00
|
|
|
|
};
|
|
|
|
|
|
2022-01-17 19:50:14 +01:00
|
|
|
|
ReactDOM.render(<Sidebar />, document.getElementById('app'));
|