To avoid the overhead of enabling legacy extensions and to simplify the code-base, this could be refactored into WebExtensions APIs. Specifically, webRequest
and notifications
E.g.,
const BREACHES_URL = "..."
let siteSet = new Set();
async function initSiteList() {
const breachesResponse = await fetch(BREACHES_URL);
const breachesJSON = breachesResponse.json();
siteSet = new Set(breachesJSON.map(site => site.Domain));
}
function initOnResponseStarted() {
browser.webRequest.onResponseStarted.addListener(details => {
if (siteSet.has(details.url.replace("www.",""))) {
notifications.create({...});
}
}...);
}
initSiteList();
initOnResponseStarted();