Compare commits

...

2 Commits

5 changed files with 38 additions and 12 deletions

View File

@ -17,10 +17,12 @@ export default class ExtendedRequest {
public requestHeaders: Request["requestHeaders"];
public origin: string;
public initialized = false;
public stolenData: StolenDataEntry[];
async init() {
await this.cacheOrigin();
this.initialized = true;
this.stolenData = this.getAllStolenData();
}
async cacheOrigin(): Promise<void> {
@ -67,13 +69,13 @@ export default class ExtendedRequest {
const path = url.pathname;
return (
this.getReferer().includes(host) ||
this.getAllStolenData().filter(
this.stolenData.filter(
(entry) => entry.value.includes(host) || entry.value.includes(path)
).length > 0
);
}
getAllStolenData(): StolenDataEntry[] {
private getAllStolenData(): StolenDataEntry[] {
return [
...this.getPathParams(),
...this.getCookieData(),

View File

@ -18,6 +18,7 @@ export class StolenDataEntry {
public isIAB = false;
public iab: TCModel | null = null;
public id: number;
public markedKeys: string[] = [];
constructor(
public request: ExtendedRequest,
@ -74,8 +75,19 @@ export class StolenDataEntry {
}
}
getParsedValue(): string | Record<string, unknown> {
return StolenDataEntry.parseValue(this.value);
getParsedValue(key_path: string): string | Record<string, unknown> {
let object = StolenDataEntry.parseValue(this.value);
console.log("key_path", key_path);
for (const key of key_path.split(".")) {
if (key === "") continue;
console.log(key, object[key]);
object = StolenDataEntry.parseValue(object[key]);
}
return object;
}
addMarkedValue(key: string) {
this.markedKeys.push(key);
}
}
@ -113,8 +125,14 @@ export class MergedStolenDataEntry {
return Array.from(new Set(this.entries.map((e) => e.value)));
}
getParsedValues() {
return Array.from(new Set(this.entries.map((e) => e.getParsedValue())));
getParsedValues(key_path: string) {
return Array.from(
new Set(this.entries.map((e) => e.getParsedValue(key_path)))
);
}
addMarkedValue(key: string) {
this.entries.forEach((entry) => entry.addMarkedValue(key));
}
}
@ -142,7 +160,7 @@ export class RequestCluster extends EventEmitter {
cookiesOnly: boolean;
}): MergedStolenDataEntry[] {
return this.requests
.map((request) => request.getAllStolenData())
.map((request) => request.stolenData)
.reduce((a, b) => a.concat(b), [])
.filter((entry) => {
return entry.value.length >= filter.minValueLength;

View File

@ -17,7 +17,7 @@ const Sidebar = () => {
const [origin, setOrigin] = useState<string | null>(null);
const [minValueLength, setMinValueLength] = useState<number | null>(7);
const [cookiesOnly, setCookiesOnly] = useState<boolean>(false);
const [counter] = useEmitter(memory);
const [counter, setCounter] = useEmitter(memory);
useEffect(() => {
const listener = async (data) => {
@ -55,6 +55,7 @@ const Sidebar = () => {
<StolenData
origin={origin}
refreshToken={counter}
refresh={() => setCounter((c) => c + 1)}
minValueLength={minValueLength}
cookiesOnly={cookiesOnly}
/>

View File

@ -45,7 +45,7 @@ function StolenDataValue({
return <StolenDataValueTable object={value} prefixKey={prefixKey} />;
}
export default function StolenDataRow({
export default function StolenDataCluster({
origin,
shorthost,
minValueLength,

View File

@ -1,17 +1,19 @@
import React from "react";
import memory from "./memory";
import { RequestCluster } from "./request-cluster";
import StolenDataRow from "./stolen-data-row";
import StolenDataCluster from "./stolen-data-cluster";
import { getshorthost } from "./util";
export function StolenData({
origin,
minValueLength,
refreshToken,
refresh,
cookiesOnly,
}: {
origin: string;
refreshToken: number;
refresh: () => void;
minValueLength: number;
cookiesOnly: boolean;
}) {
@ -40,7 +42,10 @@ export function StolenData({
</button>
<button
style={{ marginLeft: "1rem" }}
onClick={() => memory.removeRequestsFor(origin)}
onClick={() => {
memory.removeRequestsFor(origin);
refresh();
}}
>
Wyczyść pamięć
</button>
@ -49,7 +54,7 @@ export function StolenData({
.filter((cluster) => !cookiesOnly || cluster.hasCookies())
.map((cluster) => {
return (
<StolenDataRow
<StolenDataCluster
origin={origin}
shorthost={cluster.id}
key={cluster.id + origin}