forked from Stigmatoz/web-activity-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseBlockPage.ts
More file actions
21 lines (20 loc) · 745 Bytes
/
useBlockPage.ts
File metadata and controls
21 lines (20 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import Browser from 'webextension-polyfill';
import { buildBlockQuery } from '../utils/block-page';
import { NO_FAVICON } from '../utils/consts';
export async function useBlockPage(
domain: string,
url: string,
liimitTime: number,
summaryCounter: number,
favIconUrl: string | undefined,
): Promise<void> {
const favicon =
favIconUrl == undefined || favIconUrl == '' || favIconUrl.startsWith('chrome://favicon/')
? NO_FAVICON
: favIconUrl;
const blockUrl =
Browser.runtime.getURL('src/block.html') +
buildBlockQuery(domain, url, liimitTime, summaryCounter, favicon);
const tab = await Browser.tabs.query({ currentWindow: true, active: true });
await Browser.tabs.update(tab[0].id, { url: blockUrl });
}