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';
|
|
|
|
|
import Options from '../options';
|
|
|
|
|
import { StolenData } from './stolen-data';
|
2022-01-29 20:41:03 +01:00
|
|
|
|
import { useEmitter } from '../util';
|
2022-01-17 19:50:14 +01:00
|
|
|
|
import { getMemory } from '../memory';
|
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-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-01-29 21:20:25 +01:00
|
|
|
|
const [counter, setCounter] = 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(() => {
|
|
|
|
|
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-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
|
|
|
|
}
|
|
|
|
|
return setMarksOccurrence(false);
|
|
|
|
|
}, [counter, origin]);
|
2022-01-19 14:12:52 +01:00
|
|
|
|
|
2022-01-29 21:20:25 +01:00
|
|
|
|
return (
|
|
|
|
|
<div className="sidebar">
|
2022-02-02 10:33:09 +01:00
|
|
|
|
<header className={logoVisibility ? 'header' : 'header header--without-logo'}>
|
2022-01-29 21:20:25 +01:00
|
|
|
|
<img
|
|
|
|
|
src="../assets/logo-internet-czas-dzialac.svg"
|
|
|
|
|
height={40}
|
|
|
|
|
style={!logoVisibility ? { display: 'none' } : null}
|
|
|
|
|
></img>
|
|
|
|
|
<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-01-29 21:20:25 +01:00
|
|
|
|
{stolenDataView ? (
|
|
|
|
|
<nav>
|
|
|
|
|
<button onClick={() => setStolenDataView(!stolenDataView)}>
|
2022-02-02 10:33:09 +01:00
|
|
|
|
<img src="/assets/icons/settings.svg" width="20" height="20" />
|
2022-01-29 21:20:25 +01:00
|
|
|
|
<span>Ustawienia</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
getMemory().removeRequestsFor(origin);
|
|
|
|
|
setCounter((c) => c + 1);
|
|
|
|
|
setMarksOccurrence(false);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-02-02 10:33:09 +01:00
|
|
|
|
<img src="/assets/icons/trash_full.svg" width="20" height="20" />
|
2022-01-29 21:20:25 +01:00
|
|
|
|
<span>Wyczyść historię wtyczki</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
getMemory().removeCookiesFor(origin);
|
|
|
|
|
setCounter((c) => c + 1);
|
|
|
|
|
setMarksOccurrence(false);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-02-02 10:33:09 +01:00
|
|
|
|
<img src="/assets/icons/cookie.svg" width="20" height="20" />
|
2022-01-29 21:20:25 +01:00
|
|
|
|
<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
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-02-02 10:33:09 +01:00
|
|
|
|
<svg
|
2022-01-29 21:20:25 +01:00
|
|
|
|
width="20"
|
|
|
|
|
height="20"
|
2022-02-02 10:33:09 +01:00
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
|
fill="none"
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
d="M20 20H4C2.89543 20 2 19.1046 2 18V5.913C2.04661 4.84255 2.92853 3.99899 4 4H20C21.1046 4 22 4.89543 22 6V18C22 19.1046 21.1046 20 20 20ZM4 7.868V18H20V7.868L12 13.2L4 7.868ZM4.8 6L12 10.8L19.2 6H4.8Z"
|
|
|
|
|
fill="#2E3A59"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
|
2022-01-29 21:20:25 +01:00
|
|
|
|
<span>Utwórz wiadomość dla administratora witryny</span>
|
|
|
|
|
</button>
|
|
|
|
|
</nav>
|
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
|
|
<section>
|
|
|
|
|
{stolenDataView ? (
|
|
|
|
|
<>
|
|
|
|
|
{warningDataDialogAck ? (
|
|
|
|
|
<section className="warning-container">
|
|
|
|
|
<span>
|
2022-02-02 10:33:09 +01:00
|
|
|
|
<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.
|
2022-01-29 21:20:25 +01:00
|
|
|
|
</span>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setWarningDataDialogAck(false);
|
|
|
|
|
localStorage.setItem(
|
|
|
|
|
'warningDataDialogAck',
|
|
|
|
|
false as unknown as string
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-02-02 10:33:09 +01:00
|
|
|
|
<img src="/assets/icons/close_big.svg" width="16" height="16" />
|
2022-01-29 21:20:25 +01:00
|
|
|
|
</button>
|
|
|
|
|
</section>
|
|
|
|
|
) : null}
|
|
|
|
|
<StolenData
|
|
|
|
|
origin={origin}
|
|
|
|
|
refreshToken={counter}
|
|
|
|
|
refresh={() => setCounter((c) => c + 1)}
|
2022-01-23 21:42:49 +01:00
|
|
|
|
minValueLength={minValueLength}
|
|
|
|
|
cookiesOnly={cookiesOnly}
|
|
|
|
|
cookiesOrOriginOnly={cookiesOrOriginOnly}
|
|
|
|
|
/>
|
2022-01-29 21:20:25 +01:00
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<Options
|
|
|
|
|
minValueLength={minValueLength}
|
|
|
|
|
setMinValueLength={setMinValueLength}
|
|
|
|
|
cookiesOnly={cookiesOnly}
|
|
|
|
|
setCookiesOnly={setCookiesOnly}
|
|
|
|
|
cookiesOrOriginOnly={cookiesOrOriginOnly}
|
|
|
|
|
setCookiesOrOriginOnly={setCookiesOrOriginOnly}
|
|
|
|
|
warningDataDialogAck={warningDataDialogAck}
|
|
|
|
|
setWarningDataDialogAck={setWarningDataDialogAck}
|
|
|
|
|
logoVisibility={logoVisibility}
|
|
|
|
|
setLogoVisibility={setLogoVisibility}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2021-10-03 09:03:56 +02:00
|
|
|
|
};
|
2022-01-29 21:20:25 +01:00
|
|
|
|
|
2022-01-17 19:50:14 +01:00
|
|
|
|
ReactDOM.render(<Sidebar />, document.getElementById('app'));
|