Option to show only entries with either cookies or history

This commit is contained in:
Kuba Orlik 2021-11-07 19:27:03 +01:00
parent 070ac44839
commit 9b40f88db3
2 changed files with 23 additions and 0 deletions

View File

@ -5,6 +5,8 @@ export default function Options({
setMinValueLength, setMinValueLength,
cookiesOnly, cookiesOnly,
setCookiesOnly, setCookiesOnly,
cookiesOrOriginOnly,
setCookiesOrOriginOnly,
}) { }) {
return ( return (
<fieldset> <fieldset>
@ -26,6 +28,16 @@ export default function Options({
onChange={(e) => setCookiesOnly(e.target.checked)} onChange={(e) => setCookiesOnly(e.target.checked)}
/> />
<label htmlFor="cookiesOnly">Pokazuj tylko dane z cookiesów</label> <label htmlFor="cookiesOnly">Pokazuj tylko dane z cookiesów</label>
<br />
<input
type="checkbox"
id="cookiesOrOriginOnly"
value={cookiesOrOriginOnly}
onChange={(e) => setCookiesOrOriginOnly(e.target.checked)}
/>
<label htmlFor="cookiesOrOriginOnly">
Pokazuj tylko dane z cookiesów lub z częścią historii przeglądania
</label>
</fieldset> </fieldset>
); );
} }

View File

@ -26,6 +26,7 @@ export class RequestCluster extends EventEmitter {
getStolenData(filter: { getStolenData(filter: {
minValueLength: number; minValueLength: number;
cookiesOnly: boolean; cookiesOnly: boolean;
cookiesOrOriginOnly: boolean;
}): MergedStolenDataEntry[] { }): MergedStolenDataEntry[] {
return this.requests return this.requests
.map((request) => request.stolenData) .map((request) => request.stolenData)
@ -34,6 +35,12 @@ export class RequestCluster extends EventEmitter {
return entry.value.length >= filter.minValueLength; return entry.value.length >= filter.minValueLength;
}) })
.filter((entry) => !filter.cookiesOnly || entry.source === "cookie") .filter((entry) => !filter.cookiesOnly || entry.source === "cookie")
.filter(
(entry) =>
!filter.cookiesOrOriginOnly ||
entry.source === "cookie" ||
entry.classification === "history"
)
.sort((entryA, entryB) => (entryA.name > entryB.name ? -1 : 1)) .sort((entryA, entryB) => (entryA.name > entryB.name ? -1 : 1))
.filter((element, index, array) => { .filter((element, index, array) => {
// remove duplicates by name/value // remove duplicates by name/value
@ -103,4 +110,8 @@ export class RequestCluster extends EventEmitter {
.map((request) => request.getMarkedEntries()) .map((request) => request.getMarkedEntries())
.reduce(reduceConcat, []); .reduce(reduceConcat, []);
} }
exposesOrigin() {
return this.requests.some((request) => request.exposesOrigin());
}
} }