Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Whenever the active tab changes, then we update the count of blocked request
chrome.tabs.onActivated.addListener(({ tabId }: chrome.tabs.TabActiveInfo) =>
updateBlockedCounter(tabId),
);
// Reset counter if tab is reloaded
chrome.tabs.onUpdated.addListener((tabId, { status }) => {
if (status === 'loading') {
updateBlockedCounter(tabId, {
incr: false,
reset: true,
});
}
});
WebExtensionBlocker.fromPrebuiltAdsAndTracking().then((blocker: WebExtensionBlocker) => {
blocker.enableBlockingInBrowser();
blocker.on('request-blocked', incrementBlockedCounter);
blocker.on('request-redirected', incrementBlockedCounter);
blocker.on('csp-injected', (directives, request: Request) => {
console.log('csp', directives, request.url);
});
console.log('Ready to roll!');
});