import React from "react";
import { getMemory } from "../memory";
import { MergedStolenDataEntry, Sources } from "../stolen-data-entry";
import { hyphenate } from "../util";
function StolenDataValueTable({
entry,
prefixKey = "",
}: {
entry: MergedStolenDataEntry;
prefixKey: string;
}) {
return (
{Object.keys(entry.getParsedValues(prefixKey)[0]).map((key) => (
{
entry.toggleMark(prefixKey);
e.stopPropagation();
}}
>
{hyphenate(key)}
|
|
))}
);
}
function StolenDataValue({
entry,
prefixKey = "",
}: {
entry: MergedStolenDataEntry;
prefixKey?: string;
}) {
const value = entry.getParsedValues(prefixKey)[0];
let body = null;
if (!value) {
body = <>>;
} else if (typeof value === "string") {
body = (
{entry.getParsedValues(prefixKey)[0] as string}
);
} else {
body = ;
}
return (
{
entry.toggleMark(prefixKey);
e.stopPropagation();
}}
data-marks={entry.getMarkedValues().join(", ")}
>
{body}
);
}
export default function StolenDataCluster({
origin,
shorthost,
minValueLength,
cookiesOnly,
cookiesOrOriginOnly,
}: {
origin: string;
shorthost: string;
refreshToken: number;
minValueLength: number;
cookiesOnly: boolean;
cookiesOrOriginOnly: boolean;
}) {
const cluster = getMemory().getClustersForOrigin(origin)[shorthost];
const icons: Record = {
cookie: "🍪",
pathname: "🛣",
queryparams: "🅿",
header: "H",
};
return (
{cluster.getFullHosts().map((host) => (
{host},
))}
{cluster
.getStolenData({ minValueLength, cookiesOnly, cookiesOrOriginOnly })
.map((entry) => (
{entry.getNames().map(hyphenate).join(", ")}
|
{entry.getSources().map((source) => icons[source])} |
|
))}
);
}