Add automark option

This commit is contained in:
Kuba Orlik 2021-11-24 14:19:12 +01:00
parent ca5c97e6da
commit 8e7091c406
3 changed files with 72 additions and 28 deletions

View File

@ -63,8 +63,16 @@ export class RequestCluster extends EventEmitter {
return -1; return -1;
} else if (indexA > indexB) { } else if (indexA > indexB) {
return 1; return 1;
} else if (entry1.value.length > entry2.value.length) {
return -1;
} else if (entry1.value.length < entry2.value.length) {
return 1;
} else if (entry1.isMarked && !entry2.isMarked) {
return -1;
} else if (!entry1.isMarked && entry2.isMarked) {
return 1;
} else { } else {
return entry1.value.length > entry2.value.length ? -1 : 1; return 0;
} }
} }
}) })
@ -155,4 +163,10 @@ export class RequestCluster extends EventEmitter {
exposesOrigin() { exposesOrigin() {
return this.requests.some((request) => request.exposesOrigin()); return this.requests.some((request) => request.exposesOrigin());
} }
autoMark() {
this.getRepresentativeStolenData().forEach((entry) => {
entry.autoMark();
});
}
} }

View File

@ -23,8 +23,12 @@ export function StolenData({
if (!origin) { if (!origin) {
return <div></div>; return <div></div>;
} }
const clusters = Object.values(getMemory().getClustersForOrigin(origin)).sort( const clusters = Object.values(getMemory().getClustersForOrigin(origin))
RequestCluster.sortCompare .sort(RequestCluster.sortCompare)
.filter((cluster) => !cookiesOnly || cluster.hasCookies())
.filter(
(cluster) =>
!cookiesOrOriginOnly || cluster.hasCookies() || cluster.exposesOrigin()
); );
return ( return (
<div style={{ padding: "5px" }}> <div style={{ padding: "5px" }}>
@ -53,6 +57,12 @@ export function StolenData({
Wyczyść pamięć Wyczyść pamięć
</button> </button>
<button <button
onClick={() => clusters.forEach((cluster) => cluster.autoMark())}
>
Zaznacz automatycznie
</button>
<button
style={{ marginLeft: "1rem" }}
onClick={() => onClick={() =>
window.open( window.open(
`/report-window/report-window.html?origin=${origin}`, `/report-window/report-window.html?origin=${origin}`,
@ -64,15 +74,7 @@ export function StolenData({
Generuj maila Generuj maila
</button> </button>
</h1> </h1>
{clusters {clusters.map((cluster) => {
.filter((cluster) => !cookiesOnly || cluster.hasCookies())
.filter(
(cluster) =>
!cookiesOrOriginOnly ||
cluster.hasCookies() ||
cluster.exposesOrigin()
)
.map((cluster) => {
return ( return (
<StolenDataCluster <StolenDataCluster
origin={origin} origin={origin}

View File

@ -21,6 +21,7 @@ export const Classifications = <const>{
}; };
const ID_PREVIEW_MAX_LENGTH = 20; const ID_PREVIEW_MAX_LENGTH = 20;
const MIN_COOKIE_LENGTH_FOR_AUTO_MARK = 15;
const id = (function* id() { const id = (function* id() {
let i = 0; let i = 0;
@ -147,14 +148,20 @@ export class StolenDataEntry extends EventEmitter {
} }
mark() { mark() {
const had_been_marked_before = this.marked;
this.marked = true; this.marked = true;
if (!had_been_marked_before) {
this.emit("change"); this.emit("change");
} }
}
unmark() { unmark() {
const had_been_marked_before = this.marked;
this.marked = false; this.marked = false;
if (had_been_marked_before) {
this.emit("change"); this.emit("change");
} }
}
toggleMark() { toggleMark() {
if (this.marked) { if (this.marked) {
@ -171,6 +178,7 @@ export class StolenDataEntry extends EventEmitter {
[ [
this.request.origin, this.request.origin,
this.request.originalURL, this.request.originalURL,
this.request.originalPathname,
getshorthost(this.request.origin), getshorthost(this.request.origin),
].some((needle) => haystack.includes(needle)) ].some((needle) => haystack.includes(needle))
) )
@ -215,6 +223,26 @@ export class StolenDataEntry extends EventEmitter {
} }
exposesOrigin(): boolean { exposesOrigin(): boolean {
return this.value.includes(getshorthost(this.request.origin)); return (
this.value.includes(getshorthost(this.request.origin)) ||
this.value.includes(this.request.originalPathname)
);
}
autoMark() {
if (
this.classification == "history" ||
((this.source === "cookie" ||
this.name.toLowerCase().includes("id") ||
this.name.toLowerCase().includes("cookie") ||
this.name.toLowerCase().includes("ga") ||
this.name.toLowerCase().includes("fb")) &&
this.value.length > MIN_COOKIE_LENGTH_FOR_AUTO_MARK)
) {
if (this.request.shorthost.includes("google") && this.name == "CONSENT") {
return;
}
this.mark();
}
} }
} }