From 25cd2c2a0c545132f12225c66c0ac853d73863d1 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sun, 21 Nov 2021 22:38:32 +0100 Subject: [PATCH] Various improvement to make the sidebar and the email more concise --- memory.ts | 2 +- report-window/domain-summary.tsx | 39 +++++++++++++++-- report-window/report-window.tsx | 3 +- sidebar/sidebar.tsx | 4 +- sidebar/stolen-data-cluster.tsx | 74 ++++++++++++++++++++------------ stolen-data-entry.ts | 25 +++++++++-- 6 files changed, 108 insertions(+), 39 deletions(-) diff --git a/memory.ts b/memory.ts index 95cbfb6..f6da3e4 100644 --- a/memory.ts +++ b/memory.ts @@ -8,7 +8,7 @@ export default class Memory extends EventEmitter { private throttle = makeThrottle(200); async register(request: ExtendedRequest) { await request.init(); - console.log("registering request for", request.origin); + // console.log("registering request for", request.origin); if (!request.isThirdParty()) { return; } diff --git a/report-window/domain-summary.tsx b/report-window/domain-summary.tsx index 274519a..e44ee4f 100644 --- a/report-window/domain-summary.tsx +++ b/report-window/domain-summary.tsx @@ -15,6 +15,13 @@ const emailSources: Record = { queryparams: "jako część adresu URL (query-params)", }; +const source_priority: Array = [ + "cookie", + "pathname", + "queryparams", + "header", +]; + export default function DomainSummary({ cluster, }: { @@ -27,13 +34,37 @@ export default function DomainSummary({
  • Mój adres IP
  • {cluster .getMarks() - .sort((markA, markB) => - markA.entry.value > markB.entry.value ? -1 : 1 - ) + .sort((markA, markB) => { + if (markA.entry.value > markB.entry.value) { + return -1; + } else if (markA.entry.value > markB.entry.value) { + return 1; + } else { + const indexA = source_priority.indexOf(markA.source); + const indexB = source_priority.indexOf(markB.source); + if (indexA < indexB) { + return -1; + } else if (indexA > indexB) { + return 1; + } else { + return markA.name > markB.name ? -1 : 1; + } + } + }) + .filter((_, index, array) => { + if (index == 0) { + return true; + } + if (array[index].valuePreview === array[index - 1].valuePreview) { + return false; + } else { + return true; + } + }) .map((mark) => (
  • {emailClassifications[mark.classification]}{" "} - {emailSources[mark.source]} (nazwa: {mark.name},{" "} + {emailSources[mark.source]} (nazwa: {mark.name},{" "} {mark.key ? ( <> pozycja {mark.key}, diff --git a/report-window/report-window.tsx b/report-window/report-window.tsx index 3d76534..5a96be6 100644 --- a/report-window/report-window.tsx +++ b/report-window/report-window.tsx @@ -59,7 +59,7 @@ function Report() { > {mark.valuePreview} {/* always gonna have - one key, because unwrapEntry is calle above */} + one key, because unwrapEntry is called above */}