Finish initialising before connecting ports

main
Elbert Alias 4 years ago
parent 4b53c4af1b
commit 6b22d57b38

@ -7,10 +7,9 @@ const {
setCategories, setCategories,
analyze, analyze,
analyzeManyToMany, analyzeManyToMany,
resolve, resolve
open
} = Wappalyzer } = Wappalyzer
const { agent, promisify, getOption, setOption } = Utils const { agent, promisify, getOption, setOption, open } = Utils
const expiry = 1000 * 60 * 60 * 24 const expiry = 1000 * 60 * 60 * 24
@ -21,12 +20,9 @@ const Driver = {
* Initialise driver * Initialise driver
*/ */
async init() { async init() {
// Enable messaging between scripts
chrome.runtime.onConnect.addListener(Driver.onRuntimeConnect)
await Driver.loadTechnologies() await Driver.loadTechnologies()
const hostnameCache = (await getOption('hostnames')) || {} const hostnameCache = await getOption('hostnames', {})
Driver.cache = { Driver.cache = {
hostnames: Object.keys(hostnameCache).reduce( hostnames: Object.keys(hostnameCache).reduce(
@ -55,8 +51,8 @@ const Driver = {
{} {}
), ),
tabs: {}, tabs: {},
robots: (await getOption('robots')) || {}, robots: await getOption('robots', {}),
ads: (await getOption('ads')) || [] ads: await getOption('ads', [])
} }
chrome.webRequest.onCompleted.addListener( chrome.webRequest.onCompleted.addListener(
@ -66,6 +62,9 @@ const Driver = {
) )
chrome.tabs.onRemoved.addListener((id) => (Driver.cache.tabs[id] = null)) chrome.tabs.onRemoved.addListener((id) => (Driver.cache.tabs[id] = null))
// Enable messaging between scripts
chrome.runtime.onConnect.addListener(Driver.onRuntimeConnect)
const { version } = chrome.runtime.getManifest() const { version } = chrome.runtime.getManifest()
const previous = await getOption('version') const previous = await getOption('version')
const upgradeMessage = await getOption('upgradeMessage', true) const upgradeMessage = await getOption('upgradeMessage', true)

Loading…
Cancel
Save