Checkpoint
This commit is contained in:
parent
ad852a70a4
commit
86bd7f72b6
@ -1,5 +1,3 @@
|
||||
import { init } from "./memory";
|
||||
|
||||
init();
|
||||
|
||||
alert("memory initialized!");
|
||||
|
@ -14,6 +14,7 @@ const whitelisted_cookies = [
|
||||
export default class ExtendedRequest {
|
||||
public tabId: number;
|
||||
public url: string;
|
||||
public shorthost: string;
|
||||
public requestHeaders: Request["requestHeaders"];
|
||||
public origin: string;
|
||||
public initialized = false;
|
||||
@ -153,5 +154,14 @@ export default class ExtendedRequest {
|
||||
this.tabId = data.tabId;
|
||||
this.url = data.url;
|
||||
this.requestHeaders = data.requestHeaders;
|
||||
this.shorthost = getshorthost(data.url);
|
||||
}
|
||||
|
||||
hasMark() {
|
||||
return this.stolenData.some((data) => data.hasMark());
|
||||
}
|
||||
|
||||
getMarkedEntries() {
|
||||
return this.stolenData.filter((data) => data.hasMark());
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,11 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<style>
|
||||
tr:hover {
|
||||
background-color: hsla(0, 0%, 0%, 0.1);
|
||||
}
|
||||
</style>
|
||||
<script src="/lib/report-window/report-window.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,13 +1,54 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { Memory } from "../memory";
|
||||
|
||||
const memory = (window as any).memory as Memory;
|
||||
import { getMemory } from "../util";
|
||||
|
||||
function Report() {
|
||||
const origin = new URL(document.location.toString()).searchParams.get(
|
||||
"origin"
|
||||
);
|
||||
const clusters = getMemory().getClustersForOrigin(origin);
|
||||
const marked_entries = Object.values(clusters)
|
||||
.map((cluster) => cluster.getMarkedRequests())
|
||||
.reduce((a, b) => a.concat(b), [])
|
||||
.map((request) => request.getMarkedEntries())
|
||||
.reduce((a, b) => a.concat(b), []);
|
||||
return (
|
||||
<div>
|
||||
<h1>Raport</h1>
|
||||
<h1>Generuj treść maila dla {origin}</h1>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Adres docelowy</th>
|
||||
<th>Źródło danych</th>
|
||||
<th>Treść danych</th>
|
||||
<th> Klasyfikacja</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{marked_entries.map((entry) => (
|
||||
<tr>
|
||||
<td>{entry.request.shorthost}</td>
|
||||
<td>
|
||||
{entry.source}:{entry.name}
|
||||
{entry.markedKeys.join(",")}
|
||||
</td>
|
||||
<td>{entry.value}</td>
|
||||
<td>
|
||||
<select>
|
||||
{[
|
||||
["history", "Historia przeglądania"],
|
||||
["id", "Sztucznie nadane id"],
|
||||
].map(([key, name]) => (
|
||||
<option key={key} value={key}>
|
||||
{name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ export type Sources = "cookie" | "pathname" | "queryparams" | "header";
|
||||
|
||||
import { TCString, TCModel } from "@iabtcf/core";
|
||||
import { getMemory, isJSONObject, isURL, parseToObject } from "./util";
|
||||
import memory from "./memory";
|
||||
|
||||
const id = (function* id() {
|
||||
let i = 0;
|
||||
@ -37,9 +36,15 @@ export class StolenDataEntry {
|
||||
|
||||
getPriority() {
|
||||
let priority = 0;
|
||||
priority += Math.min(this.value.length, 100);
|
||||
priority += Math.min(this.value.length, 50);
|
||||
const url = new URL(this.request.getOrigin());
|
||||
if (this.value.includes(url.host) || this.value.includes(url.pathname)) {
|
||||
if (this.value.includes(url.host)) {
|
||||
priority += 100;
|
||||
}
|
||||
if (this.value.includes(url.pathname)) {
|
||||
priority += 100;
|
||||
}
|
||||
if (this.source === "cookie") {
|
||||
priority += 100;
|
||||
}
|
||||
return priority;
|
||||
@ -90,8 +95,12 @@ export class StolenDataEntry {
|
||||
getMemory().emit("change"); // to trigger rerender
|
||||
}
|
||||
|
||||
hasMark(key: string) {
|
||||
return this.markedKeys.some((k) => k == key);
|
||||
hasMark(key?: string) {
|
||||
if (key) {
|
||||
return this.markedKeys.some((k) => k == key);
|
||||
} else {
|
||||
return this.markedKeys.length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
removeMark(key: string) {
|
||||
@ -244,4 +253,8 @@ export class RequestCluster extends EventEmitter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getMarkedRequests() {
|
||||
return this.requests.filter((request) => request.hasMark());
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ export function StolenData({
|
||||
<button
|
||||
onClick={() =>
|
||||
window.open(
|
||||
"/report-window/report-window.html",
|
||||
`/report-window/report-window.html?origin=${origin}`,
|
||||
"new_window",
|
||||
"width=800,height=600"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user