diff --git a/extended-request.ts b/extended-request.ts index cff37c9..5884459 100644 --- a/extended-request.ts +++ b/extended-request.ts @@ -1,3 +1,4 @@ +import { StolenDataEntry } from "./request-cluster"; import { getshorthost, Request } from "./util"; export default class ExtendedRequest { @@ -52,6 +53,21 @@ export default class ExtendedRequest { return this.requestHeaders.find((h) => h.name == "Cookie")?.value; } + getPathParams(): StolenDataEntry[] { + const url = new URL(this.data.url); + const path = url.pathname; + if (!path.includes(";")) { + return []; + } + return path + .split(";") + .map((e) => e.split("=")) + .map( + ([key, value]) => + new StolenDataEntry("pathname", key, decodeURIComponent(value)) + ); + } + constructor(public data: Request) { this.tabId = data.tabId; this.url = data.url; diff --git a/request-cluster.ts b/request-cluster.ts index ef13518..c8c629c 100644 --- a/request-cluster.ts +++ b/request-cluster.ts @@ -2,6 +2,10 @@ import { EventEmitter } from "events"; import ExtendedRequest from "./extended-request"; import { parseCookie } from "./util"; +export class StolenDataEntry { + constructor(public type: string, public name: string, public value: string) {} +} + export class RequestCluster extends EventEmitter { public requests: ExtendedRequest[] = []; constructor(public id: string) { @@ -25,7 +29,8 @@ export class RequestCluster extends EventEmitter { minValueLength, }: { minValueLength: number; - }): [string, string][] { + }): StolenDataEntry[] { + this.getQueryParamsContent({ minValueLength }); const cookieValues = new Set(); for (const request of this.requests) { if (request.hasCookie()) { @@ -36,7 +41,40 @@ export class RequestCluster extends EventEmitter { .map(parseCookie) .map((o) => Object.entries(o)) .reduce((a, b) => a.concat(b), []) - .filter(([_, value]) => value.length >= minValueLength); + .map(([key, value]) => new StolenDataEntry("cookie", key, value)) + .filter((e) => e.value.length >= minValueLength); + } + + getQueryParamsContent({ + minValueLength, + }: { + minValueLength: number; + }): StolenDataEntry[] { + const result = []; + for (const request of this.requests) { + console.log(request.data.url); + } + return result; + } + + getPathnameParamsContent({ + minValueLength, + }: { + minValueLength: number; + }): StolenDataEntry[] { + let result = []; + for (const request of this.requests) { + result = [...result, ...request.getPathParams()]; + } + console.log("PATHNAME PARAMS FOR", this.id, result); + return result; + } + + getStolenData(filter: { minValueLength: number }) { + return [ + ...this.getCookiesContent(filter), + ...this.getPathnameParamsContent(filter), + ]; } static sortCompare(a: RequestCluster, b: RequestCluster) { diff --git a/sidebar.tsx b/sidebar.tsx index d54f0e1..5c37956 100644 --- a/sidebar.tsx +++ b/sidebar.tsx @@ -68,16 +68,14 @@ const StolenDataRow = ({ - {cluster - .getCookiesContent({ minValueLength }) - .map(([cookie_name, cookie_value]) => ( - - - - - ))} + {cluster.getStolenData({ minValueLength }).map((entry) => ( + + + + + ))}
- {cookie_name} - {cookie_value}
+ {entry.name} + {entry.value}
@@ -107,7 +105,9 @@ const StolenData = ({
{" "}
- {tab.title} +

+ {tab.title} +

{clusters.map((cluster) => ( { + return ( +
+

Zaawansowane ustawienia

+ + setMinValueLength(parseInt(e.target.value))} + /> +
+ ); +}; + const Sidebar = () => { console.log("rendering!"); const [pickedTab, setPickedTab] = useState(null); - const [minValueLength, setMinValueLength] = useState(3); + const [minValueLength, setMinValueLength] = useState(5); const counter = useEmitter(memory); return ( <> @@ -138,10 +155,9 @@ const Sidebar = () => { Wybierz aktywną kartę{" "}
- setMinValueLength(parseInt(e.target.value))} +