rentgen/sidebar/stolen-data.tsx

94 lines
2.4 KiB
TypeScript
Raw Normal View History

2021-11-07 09:17:19 +01:00
import React from "react";
2021-11-07 13:01:01 +01:00
import { RequestCluster } from "../request-cluster";
2021-11-07 17:23:48 +01:00
import StolenDataCluster from "./stolen-data-cluster";
2021-11-07 17:23:48 +01:00
import { getshorthost } from "../util";
import { getMemory } from "../memory";
2021-11-07 09:17:19 +01:00
export function StolenData({
origin,
minValueLength,
refreshToken,
refresh,
2021-11-07 09:17:19 +01:00
cookiesOnly,
2021-11-07 19:28:07 +01:00
cookiesOrOriginOnly,
2021-11-07 09:17:19 +01:00
}: {
origin: string;
refreshToken: number;
refresh: () => void;
2021-11-07 09:17:19 +01:00
minValueLength: number;
cookiesOnly: boolean;
2021-11-07 19:28:07 +01:00
cookiesOrOriginOnly: boolean;
2021-11-07 09:17:19 +01:00
}) {
if (!origin) {
return <div></div>;
}
2021-11-24 14:19:12 +01:00
const clusters = Object.values(getMemory().getClustersForOrigin(origin))
.sort(RequestCluster.sortCompare)
.filter((cluster) => !cookiesOnly || cluster.hasCookies())
.filter(
(cluster) =>
!cookiesOrOriginOnly || cluster.hasCookies() || cluster.exposesOrigin()
);
2021-11-07 09:17:19 +01:00
return (
<div style={{ padding: "5px" }}>
{" "}
<div>
<h1>
{origin}
<button
style={{ marginLeft: "1rem" }}
onClick={() =>
2021-11-07 13:57:24 +01:00
getMemory().removeCookiesFor(
2021-11-07 09:17:19 +01:00
origin,
getshorthost(new URL(origin).host)
)
}
>
Wyczyść cookiesy 1st party
</button>
<button
style={{ marginLeft: "1rem" }}
onClick={() => {
2021-11-07 13:57:24 +01:00
getMemory().removeRequestsFor(origin);
refresh();
}}
2021-11-07 09:17:19 +01:00
>
Wyczyść pamięć
</button>
2021-11-07 13:57:24 +01:00
<button
2021-11-24 14:19:12 +01:00
onClick={() => clusters.forEach((cluster) => cluster.autoMark())}
>
Zaznacz automatycznie
</button>
<button
style={{ marginLeft: "1rem" }}
2021-11-07 13:57:24 +01:00
onClick={() =>
window.open(
2021-11-07 15:45:26 +01:00
`/report-window/report-window.html?origin=${origin}`,
2021-11-07 13:57:24 +01:00
"new_window",
"width=800,height=600"
)
}
>
Generuj maila
</button>
2021-11-07 09:17:19 +01:00
</h1>
2021-11-24 14:19:12 +01:00
{clusters.map((cluster) => {
return (
<StolenDataCluster
origin={origin}
shorthost={cluster.id}
key={cluster.id + origin}
refreshToken={refreshToken}
minValueLength={minValueLength}
cookiesOnly={cookiesOnly}
cookiesOrOriginOnly={cookiesOrOriginOnly}
/>
);
})}
2021-11-07 09:17:19 +01:00
</div>
</div>
);
}