rentgen/sidebar/stolen-data.tsx

105 lines
3.2 KiB
TypeScript
Raw Normal View History

2022-01-19 13:12:28 +01:00
import React from 'react';
import { RequestCluster } from '../request-cluster';
2021-11-07 17:23:48 +01:00
2022-01-19 13:12:28 +01:00
import StolenDataCluster from './stolen-data-cluster';
import { getshorthost } from '../util';
import { getMemory } from '../memory';
2021-11-07 09:17:19 +01:00
2022-01-20 19:03:03 +01:00
import './stolen-data.scss';
2021-11-07 09:17:19 +01:00
export function StolenData({
2022-01-19 13:12:28 +01:00
origin,
minValueLength,
refreshToken,
refresh,
cookiesOnly,
cookiesOrOriginOnly,
2021-11-07 09:17:19 +01:00
}: {
2022-01-19 13:12:28 +01:00
origin: string;
refreshToken: number;
refresh: () => void;
minValueLength: number;
cookiesOnly: boolean;
cookiesOrOriginOnly: boolean;
2021-11-07 09:17:19 +01:00
}) {
2022-01-19 13:12:28 +01:00
if (!origin) {
2022-01-20 19:03:03 +01:00
return (
<div className="stolen-data-container">
<span>Otwórz nową kartę z wybraną stroną internetową</span>
</div>
);
2022-01-19 13:12:28 +01:00
}
const clusters = Object.values(getMemory().getClustersForOrigin(origin))
.sort(RequestCluster.sortCompare)
.filter((cluster) => !cookiesOnly || cluster.hasCookies())
.filter(
(cluster) =>
!cookiesOrOriginOnly ||
cluster.hasCookies() ||
cluster.exposesOrigin()
);
return (
2022-01-20 19:03:03 +01:00
<div className="stolen-data-container">
{/* <button
2022-01-19 13:12:28 +01:00
style={{ marginLeft: '1rem' }}
onClick={() =>
getMemory().removeCookiesFor(
origin,
getshorthost(new URL(origin).host)
)
}
>
Wyczyść cookiesy 1st party
</button>
<button
style={{ marginLeft: '1rem' }}
onClick={() => {
getMemory().removeRequestsFor(origin);
refresh();
}}
>
Wyczyść pamięć
</button> */}
2022-01-19 14:30:05 +01:00
2022-01-20 19:03:03 +01:00
{/* <button
2022-01-19 13:12:28 +01:00
style={{ marginLeft: '1rem' }}
onClick={() =>
window.open(
`/report-window/report-window.html?origin=${origin}`,
'new_window',
'width=800,height=600'
)
}
>
Generuj maila
</button> */}
2022-01-20 19:03:03 +01:00
{/* <button
2022-01-19 14:30:05 +01:00
onClick={() => {
clusters.forEach((cluster) => cluster.autoMark());
refresh();
}}
>
Zaznacz automatycznie
</button> */}
2022-01-23 21:42:49 +01:00
<span>Domeny oraz przesłane informacje</span>
2022-01-20 19:03:03 +01:00
{clusters.map((cluster) => {
return (
<StolenDataCluster
origin={origin}
shorthost={cluster.id}
key={cluster.id + origin}
refresh={refresh}
refreshToken={refreshToken}
minValueLength={minValueLength}
cookiesOnly={cookiesOnly}
cookiesOrOriginOnly={cookiesOrOriginOnly}
/>
);
})}
2022-01-19 13:12:28 +01:00
</div>
2021-11-24 14:19:12 +01:00
);
2021-11-07 09:17:19 +01:00
}