Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/js/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import './globals';

import {DYNAMIC_STRING_MARKER, Origin, STATES} from './config';
import {MESSAGE_TYPE, ORIGIN_HOST} from './config';

Expand Down
8 changes: 2 additions & 6 deletions src/js/background/historyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ export async function getRecords(): Promise<
[string, {creationTime: number; violations: Array<Violation>; url: string}]
>
> {
const tabIDs = await chrome.storage.local.getKeys();
const entries = await chrome.storage.local.get(tabIDs);
return Object.entries(entries);
return Object.entries(await chrome.storage.local.get(null));
}

export async function downloadHashSource(
Expand Down Expand Up @@ -105,10 +103,8 @@ export async function trackViolationForTab(

export async function setUpHistoryCleaner(): Promise<void> {
const now = Date.now();
const keys = await chrome.storage.local.getKeys();
const entries = await chrome.storage.local.get(keys);

const entriesToDelete = Object.entries(entries)
const entriesToDelete = (await getRecords())
.filter(([_keys, entry]) => now - entry.creationTime >= HISTORY_TTL_MSEC)
.map(entry => entry[0]);

Expand Down
2 changes: 2 additions & 0 deletions src/js/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import './globals';

import {
MESSAGE_TYPE,
DOWNLOAD_SRC_ENABLED,
Expand Down
10 changes: 10 additions & 0 deletions src/js/globals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

// See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Chrome_incompatibilities
// To enable Promise APIs we need to use `browser` outside of Chrome
self.chrome = self.browser ?? self.chrome;
4 changes: 1 addition & 3 deletions src/js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ declare global {
showSaveFilePicker: (_: {
suggestedName: string;
}) => Promise<FileSystemFileHandle>;
}
interface FileSystemFileHandle {
createWritable: () => Promise<WritableStream>;
browser: typeof chrome;
}
}
2 changes: 2 additions & 0 deletions src/js/popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import '../globals';

import type {Origin, State} from '../config';
import {
DOWNLOAD_SRC_ENABLED,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"strict": true,
"target": "ES6"
"target": "ES2017"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we go higher?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, I'll look into it as a follow up.

}
}