Checkpoint
This commit is contained in:
parent
ad852a70a4
commit
86bd7f72b6
@ -1,5 +1,3 @@
|
|||||||
import { init } from "./memory";
|
import { init } from "./memory";
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
alert("memory initialized!");
|
|
||||||
|
@ -14,6 +14,7 @@ const whitelisted_cookies = [
|
|||||||
export default class ExtendedRequest {
|
export default class ExtendedRequest {
|
||||||
public tabId: number;
|
public tabId: number;
|
||||||
public url: string;
|
public url: string;
|
||||||
|
public shorthost: string;
|
||||||
public requestHeaders: Request["requestHeaders"];
|
public requestHeaders: Request["requestHeaders"];
|
||||||
public origin: string;
|
public origin: string;
|
||||||
public initialized = false;
|
public initialized = false;
|
||||||
@ -153,5 +154,14 @@ export default class ExtendedRequest {
|
|||||||
this.tabId = data.tabId;
|
this.tabId = data.tabId;
|
||||||
this.url = data.url;
|
this.url = data.url;
|
||||||
this.requestHeaders = data.requestHeaders;
|
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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<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>
|
<script src="/lib/report-window/report-window.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,13 +1,54 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import { Memory } from "../memory";
|
import { getMemory } from "../util";
|
||||||
|
|
||||||
const memory = (window as any).memory as Memory;
|
|
||||||
|
|
||||||
function Report() {
|
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 (
|
return (
|
||||||
<div>
|
<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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ export type Sources = "cookie" | "pathname" | "queryparams" | "header";
|
|||||||
|
|
||||||
import { TCString, TCModel } from "@iabtcf/core";
|
import { TCString, TCModel } from "@iabtcf/core";
|
||||||
import { getMemory, isJSONObject, isURL, parseToObject } from "./util";
|
import { getMemory, isJSONObject, isURL, parseToObject } from "./util";
|
||||||
import memory from "./memory";
|
|
||||||
|
|
||||||
const id = (function* id() {
|
const id = (function* id() {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
@ -37,9 +36,15 @@ export class StolenDataEntry {
|
|||||||
|
|
||||||
getPriority() {
|
getPriority() {
|
||||||
let priority = 0;
|
let priority = 0;
|
||||||
priority += Math.min(this.value.length, 100);
|
priority += Math.min(this.value.length, 50);
|
||||||
const url = new URL(this.request.getOrigin());
|
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;
|
priority += 100;
|
||||||
}
|
}
|
||||||
return priority;
|
return priority;
|
||||||
@ -90,8 +95,12 @@ export class StolenDataEntry {
|
|||||||
getMemory().emit("change"); // to trigger rerender
|
getMemory().emit("change"); // to trigger rerender
|
||||||
}
|
}
|
||||||
|
|
||||||
hasMark(key: string) {
|
hasMark(key?: string) {
|
||||||
return this.markedKeys.some((k) => k == key);
|
if (key) {
|
||||||
|
return this.markedKeys.some((k) => k == key);
|
||||||
|
} else {
|
||||||
|
return this.markedKeys.length > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeMark(key: string) {
|
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
|
<button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
window.open(
|
window.open(
|
||||||
"/report-window/report-window.html",
|
`/report-window/report-window.html?origin=${origin}`,
|
||||||
"new_window",
|
"new_window",
|
||||||
"width=800,height=600"
|
"width=800,height=600"
|
||||||
)
|
)
|
||||||
|
7
util.ts
7
util.ts
@ -11,7 +11,12 @@ export type Request = Parameters<
|
|||||||
>[0];
|
>[0];
|
||||||
|
|
||||||
export function getshorthost(host: string) {
|
export function getshorthost(host: string) {
|
||||||
return host.split(".").slice(-2).join(".");
|
return host
|
||||||
|
.replace(/^.*:\/\//, "")
|
||||||
|
.replace(/\/.*$/, "")
|
||||||
|
.split(".")
|
||||||
|
.slice(-2)
|
||||||
|
.join(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useEmitter(
|
export function useEmitter(
|
||||||
|
Loading…
Reference in New Issue
Block a user