diff --git a/src/drivers/webextension/js/content.js b/src/drivers/webextension/js/content.js index f30257901..d0209af65 100644 --- a/src/drivers/webextension/js/content.js +++ b/src/drivers/webextension/js/content.js @@ -31,7 +31,7 @@ function getJs(technologies) { }) } - script.setAttribute('src', chrome.extension.getURL('js/inject.js')) + script.setAttribute('src', chrome.runtime.getURL('js/inject.js')) document.body.appendChild(script) }) @@ -129,7 +129,9 @@ const Content = { * Initialise content script */ async init() { - if (await Content.driver('isDisabledDomain', location.href)) { + const url = location.href + + if (await Content.driver('isDisabledDomain', url)) { return } @@ -236,7 +238,7 @@ const Content = { Content.cache = { html, css, scripts, meta } await Content.driver('onContentLoad', [ - location.href, + url, Content.cache, Content.language, ]) @@ -313,7 +315,7 @@ const Content = { }) }, - async analyzeRequires(requires) { + async analyzeRequires(url, requires) { await Promise.all( Object.keys(requires).map(async (name) => { if (!Content.analyzedRequires.includes(name)) { @@ -324,7 +326,7 @@ const Content = { await Promise.all([ Content.onGetTechnologies(technologies, name), Content.driver('onContentLoad', [ - location.href, + url, Content.cache, Content.language, name, @@ -340,12 +342,14 @@ const Content = { * @param {Array} technologies */ async onGetTechnologies(technologies = [], requires) { + const url = location.href + const js = await getJs(technologies) const dom = getDom(technologies) await Promise.all([ - Content.driver('analyzeJs', [location.href, js, requires]), - Content.driver('analyzeDom', [location.href, dom, requires]), + Content.driver('analyzeJs', [url, js, requires]), + Content.driver('analyzeDom', [url, dom, requires]), ]) }, } diff --git a/src/drivers/webextension/js/driver.js b/src/drivers/webextension/js/driver.js index 4cef32a63..8730a15f8 100644 --- a/src/drivers/webextension/js/driver.js +++ b/src/drivers/webextension/js/driver.js @@ -137,7 +137,7 @@ const Driver = { async loadTechnologies() { try { const { technologies, categories } = await ( - await fetch(chrome.extension.getURL('technologies.json')) + await fetch(chrome.runtime.getURL('technologies.json')) ).json() setTechnologies(technologies) @@ -503,6 +503,8 @@ const Driver = { cache.dateTime = Date.now() + console.log('xxx', { url, hostname, cache, detections }) + // Remove duplicates cache.detections = cache.detections .concat(detections) @@ -588,7 +590,7 @@ const Driver = { ) try { - await Driver.content(url, 'analyzeRequires', [requires]) + await Driver.content(url, 'analyzeRequires', [url, requires]) } catch (error) { // Continue } @@ -682,7 +684,7 @@ const Driver = { chrome.browserAction.setIcon( { tabId, - path: chrome.extension.getURL( + path: chrome.runtime.getURL( `../images/icons/${ /\.svg$/i.test(icon) ? `converted/${icon.replace(/\.svg$/, '.png')}` diff --git a/src/drivers/webextension/js/utils.js b/src/drivers/webextension/js/utils.js index c4253096d..e58d96158 100644 --- a/src/drivers/webextension/js/utils.js +++ b/src/drivers/webextension/js/utils.js @@ -3,9 +3,9 @@ /* globals chrome */ const Utils = { - agent: chrome.extension.getURL('/').startsWith('moz-') + agent: chrome.runtime.getURL('/').startsWith('moz-') ? 'firefox' - : chrome.extension.getURL('/').startsWith('safari-') + : chrome.runtime.getURL('/').startsWith('safari-') ? 'safari' : 'chrome',