diff --git a/report-window/report-window.tsx b/report-window/report-window.tsx index d7f25ec..6d36b67 100644 --- a/report-window/report-window.tsx +++ b/report-window/report-window.tsx @@ -21,20 +21,22 @@ function Report() { Adres docelowy Źródło danych Treść danych - Klasyfikacja + Klasyfikacja {marked_entries.map((entry) => ( {entry.request.shorthost} - + {entry.source}:{entry.name} {entry.markedKeys.join(",")} - {entry.value} + + {entry.value} + - {[ ["history", "Historia przeglądania"], ["id", "Sztucznie nadane id"], diff --git a/stolen-data-entry.ts b/stolen-data-entry.ts index c371584..0f2309f 100644 --- a/stolen-data-entry.ts +++ b/stolen-data-entry.ts @@ -1,10 +1,21 @@ import { TCModel } from "@iabtcf/core"; import ExtendedRequest from "./extended-request"; import { getMemory } from "./memory"; -import { isJSONObject, isURL, parseToObject } from "./util"; +import { + isJSONObject, + isURL, + parseToObject, + reduceConcat, + unique, +} from "./util"; export type Sources = "cookie" | "pathname" | "queryparams" | "header"; +export const Classifications = { + id: "Sztucznie nadane ID", + history: "Część historii przeglądania", +}; + const id = (function* id() { let i = 0; while (true) { @@ -18,6 +29,7 @@ export class StolenDataEntry { public iab: TCModel | null = null; public id: number; public markedKeys: string[] = []; + public classification: keyof typeof Classifications; constructor( public request: ExtendedRequest, @@ -31,6 +43,7 @@ export class StolenDataEntry { // this.isIAB = true; // } catch (e) {} this.id = id.next().value as number; + this.classification = this.classify(); } getPriority() { @@ -112,10 +125,26 @@ export class StolenDataEntry { this.addMark(key); } } + + private classify(): keyof typeof Classifications { + if (this.value.includes(this.request.origin)) { + return "history"; + } else { + return "id"; + } + } } export class MergedStolenDataEntry { - constructor(public entries: StolenDataEntry[]) {} + constructor(public entries: StolenDataEntry[]) { + const all_marks = unique( + entries.map((entry) => entry.markedKeys).reduce(reduceConcat, []) + ); + for (const entry of entries) { + entry.markedKeys = all_marks; + } + // getMemory().emit("change"); // to trigger render + } hasValue(value: string) { return this.entries.some((entry) => entry.value === value); diff --git a/util.ts b/util.ts index 8ca703b..2c31532 100644 --- a/util.ts +++ b/util.ts @@ -95,3 +95,7 @@ export function allSubhosts(host: string) { } return result; } + +export function reduceConcat(a: T[], b: T[]): T[] { + return a.concat(b); +}