-
Notifications
You must be signed in to change notification settings - Fork 2
/
background.js
25 lines (23 loc) · 851 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { anonymize, getSetting } from "./utils.js";
chrome.runtime.onInstalled.addListener(function () {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function () {
chrome.declarativeContent.onPageChanged.addRules([
{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { urlMatches: "(azure|github|microsoft).com" },
}),
],
actions: [new chrome.declarativeContent.ShowPageAction()],
},
]);
});
});
chrome.tabs.onUpdated.addListener(async function (tabId, changeInfo, tab) {
if (/(azure|github|microsoft).com/.test(tab.url)) {
if (changeInfo.status == "complete" && tab.active) {
const shouldAnonymize = await getSetting("anonymize");
setTimeout(async (_) => await anonymize(shouldAnonymize), 1000);
}
}
});