This commit is contained in:
Arkadiusz Wieczorek 2022-01-19 14:12:52 +01:00
parent 268f9a7d06
commit 33a25a3e9d
4 changed files with 195 additions and 145 deletions

View File

@ -63,6 +63,13 @@ nav {
} }
} }
&:disabled {
color: $light-grey;
svg path {
fill: $light-grey;
}
}
span { span {
padding-left: 0.5rem; padding-left: 0.5rem;
font-size: 0.875rem; font-size: 0.875rem;

View File

@ -4,7 +4,6 @@ import Options from '../options';
import { StolenData } from './stolen-data'; import { StolenData } from './stolen-data';
import { getshorthost, useEmitter } from '../util'; import { getshorthost, useEmitter } from '../util';
import { getMemory } from '../memory'; import { getMemory } from '../memory';
import { RequestCluster } from '../request-cluster';
import InfoCircleIcon from '../assets/icons/info_circle_outline.svg'; import InfoCircleIcon from '../assets/icons/info_circle_outline.svg';
import SettingsIcon from '../assets/icons/settings.svg'; import SettingsIcon from '../assets/icons/settings.svg';
import TrashIcon from '../assets/icons/trash_full.svg'; import TrashIcon from '../assets/icons/trash_full.svg';
@ -30,6 +29,7 @@ const Sidebar = () => {
const [cookiesOrOriginOnly, setCookiesOrOriginOnly] = const [cookiesOrOriginOnly, setCookiesOrOriginOnly] =
useState<boolean>(false); useState<boolean>(false);
const [counter, setCounter] = useEmitter(getMemory()); const [counter, setCounter] = useEmitter(getMemory());
const [marksOccurrence, setMarksOccurrence] = useState<boolean>(false);
useEffect(() => { useEffect(() => {
const listener = async (data: any) => { const listener = async (data: any) => {
@ -47,6 +47,18 @@ const Sidebar = () => {
}; };
}); });
useEffect(() => {
for (const cluster of Object.values(
getMemory().getClustersForOrigin(origin)
)) {
if (cluster.hasMarks()) {
return setMarksOccurrence(true);
}
}
return setMarksOccurrence(false);
}, [counter]);
return ( return (
<Fragment> <Fragment>
{/* <div id="selector"> {/* <div id="selector">
@ -93,15 +105,28 @@ const Sidebar = () => {
origin, origin,
getshorthost(new URL(origin).host) getshorthost(new URL(origin).host)
); );
setMarksOccurrence(false);
}} }}
> >
{/* {stolenDataView ? 'Options' : 'Data'} {/* {stolenDataView ? 'Options' : 'Data'}
*/} */}
<TrashIcon /> <TrashIcon />
<span>Wyczyść ciasteczka tej domeny</span> <span>Wyczyść ciasteczka first-party</span>
</button> </button>
<button <button
// disabled={RequestCluster.hasMarks()} onClick={() => {
getMemory().removeRequestsFor(origin);
setCounter((c) => c + 1);
setMarksOccurrence(false);
}}
>
{/* {stolenDataView ? 'Options' : 'Data'}
*/}
<TrashIcon />
<span>Wyczyść pamięć</span>
</button>
<button
disabled={!marksOccurrence}
onClick={() => { onClick={() => {
const params = [ const params = [
'height=' + screen.height, 'height=' + screen.height,
@ -142,7 +167,7 @@ const Sidebar = () => {
)} )}
</section> </section>
<footer>Footer</footer> <footer>Footer marks {JSON.stringify(marksOccurrence)}</footer>
</Fragment> </Fragment>
); );
}; };

View File

@ -1,8 +1,8 @@
import React from "react"; import React from 'react';
import { getMemory } from "../memory"; import { getMemory } from '../memory';
import { StolenDataEntry } from "../stolen-data-entry"; import { StolenDataEntry } from '../stolen-data-entry';
import { maskString, useEmitter } from "../util"; import { maskString, useEmitter } from '../util';
const MAX_STRING_VALUE_LENGTH = 100; const MAX_STRING_VALUE_LENGTH = 100;
@ -29,14 +29,20 @@ function StolenDataValue({
entry.toggleMark(); entry.toggleMark();
e.stopPropagation(); e.stopPropagation();
}} }}
style={{ color: entry.isMarked ? "black" : "gray" }} style={{ color: entry.isMarked ? 'black' : 'gray' }}
> >
{body} {body}
</div> </div>
); );
} }
function StolenDataRow({ entry }: { entry: StolenDataEntry }) { function StolenDataRow({
entry,
refresh,
}: {
entry: StolenDataEntry;
refresh: Function;
}) {
const [version] = useEmitter(entry); const [version] = useEmitter(entry);
return ( return (
<tr data-key={entry.id} data-version={version}> <tr data-key={entry.id} data-version={version}>
@ -44,26 +50,32 @@ function StolenDataRow({ entry }: { entry: StolenDataEntry }) {
<input <input
type="checkbox" type="checkbox"
checked={entry.isMarked} checked={entry.isMarked}
onChange={() => entry.toggleMark()} onChange={() => {
entry.toggleMark();
refresh();
}}
/> />
</td> </td>
<th <th
style={{ style={{
width: "100px", width: '100px',
overflowWrap: "anywhere", overflowWrap: 'anywhere',
}}
title={'Źródło: ' + entry.source}
onClick={() => {
entry.toggleMark();
refresh();
}} }}
title={"Źródło: " + entry.source}
onClick={() => entry.toggleMark()}
> >
{entry.name} {entry.name}
</th> </th>
<td style={{ whiteSpace: "nowrap" }}> <td style={{ whiteSpace: 'nowrap' }}>
{entry.source === "cookie" ? ( {entry.source === 'cookie' ? (
<span title="Dane przechowywane w Cookies">🍪</span> <span title="Dane przechowywane w Cookies">🍪</span>
) : entry.request.hasCookie() ? ( ) : entry.request.hasCookie() ? (
<span <span
title="Wysłane w zapytaniu opatrzonym cookies" title="Wysłane w zapytaniu opatrzonym cookies"
style={{ opacity: 0.5, fontSize: "0.5em" }} style={{ opacity: 0.5, fontSize: '0.5em' }}
> >
🍪 🍪
</span> </span>
@ -73,13 +85,13 @@ function StolenDataRow({ entry }: { entry: StolenDataEntry }) {
) : entry.request.exposesOrigin() ? ( ) : entry.request.exposesOrigin() ? (
<span <span
title="Jest częścią zapytania, które ujawnia historię przeglądania" title="Jest częścią zapytania, które ujawnia historię przeglądania"
style={{ opacity: 0.5, fontSize: "0.5em" }} style={{ opacity: 0.5, fontSize: '0.5em' }}
> >
</span> </span>
) : null} ) : null}
</td> </td>
<td style={{ wordWrap: "anywhere" as any }}> <td style={{ wordWrap: 'anywhere' as any }}>
<StolenDataValue entry={entry} /> <StolenDataValue entry={entry} />
</td> </td>
</tr> </tr>
@ -90,6 +102,7 @@ export default function StolenDataCluster({
origin, origin,
shorthost, shorthost,
minValueLength, minValueLength,
refresh,
cookiesOnly, cookiesOnly,
cookiesOrOriginOnly, cookiesOrOriginOnly,
}: { }: {
@ -97,6 +110,7 @@ export default function StolenDataCluster({
shorthost: string; shorthost: string;
refreshToken: number; refreshToken: number;
minValueLength: number; minValueLength: number;
refresh: Function;
cookiesOnly: boolean; cookiesOnly: boolean;
cookiesOrOriginOnly: boolean; cookiesOrOriginOnly: boolean;
}) { }) {
@ -104,8 +118,8 @@ export default function StolenDataCluster({
return ( return (
<div> <div>
<h2> <h2>
<a href={"https://" + cluster.id}>{cluster.id}</a>{" "} <a href={'https://' + cluster.id}>{cluster.id}</a>{' '}
{cluster.hasCookies() ? "🍪" : ""} x{cluster.requests.length}{" "} {cluster.hasCookies() ? '🍪' : ''} x{cluster.requests.length}{' '}
{/* <a {/* <a
* href="#" * href="#"
* style={{ fontSize: "10px" }} * style={{ fontSize: "10px" }}
@ -115,9 +129,10 @@ export default function StolenDataCluster({
* </a> */} * </a> */}
<a <a
href="#" href="#"
style={{ fontSize: "10px" }} style={{ fontSize: '10px' }}
onClick={(e) => { onClick={(e) => {
cluster.autoMark(); cluster.autoMark();
refresh();
e.preventDefault(); e.preventDefault();
}} }}
> >
@ -127,7 +142,7 @@ export default function StolenDataCluster({
<div> <div>
{cluster.getFullHosts().map((host) => ( {cluster.getFullHosts().map((host) => (
<a key={host} href={`https://${host}`}> <a key={host} href={`https://${host}`}>
{host},{" "} {host},{' '}
</a> </a>
))} ))}
</div> </div>
@ -141,6 +156,7 @@ export default function StolenDataCluster({
}) })
.map((entry) => ( .map((entry) => (
<StolenDataRow <StolenDataRow
refresh={refresh}
{...{ {...{
entry, entry,
key: entry.id, key: entry.id,

View File

@ -56,9 +56,10 @@ export function StolenData({
Wyczyść pamięć Wyczyść pamięć
</button> */} </button> */}
<button <button
onClick={() => onClick={() => {
clusters.forEach((cluster) => cluster.autoMark()) clusters.forEach((cluster) => cluster.autoMark());
} refresh();
}}
> >
Zaznacz automatycznie Zaznacz automatycznie
</button> </button>
@ -81,6 +82,7 @@ export function StolenData({
origin={origin} origin={origin}
shorthost={cluster.id} shorthost={cluster.id}
key={cluster.id + origin} key={cluster.id + origin}
refresh={refresh}
refreshToken={refreshToken} refreshToken={refreshToken}
minValueLength={minValueLength} minValueLength={minValueLength}
cookiesOnly={cookiesOnly} cookiesOnly={cookiesOnly}