From 6b22d57b38fee5bb6c56817921f6a640c7cf74e0 Mon Sep 17 00:00:00 2001 From: Elbert Alias <77259+AliasIO@users.noreply.github.com> Date: Wed, 17 Jun 2020 08:10:16 +1000 Subject: [PATCH] Finish initialising before connecting ports --- src/drivers/webextension/js/driver.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/drivers/webextension/js/driver.js b/src/drivers/webextension/js/driver.js index 6bd70cb1c..b312a4225 100644 --- a/src/drivers/webextension/js/driver.js +++ b/src/drivers/webextension/js/driver.js @@ -7,10 +7,9 @@ const { setCategories, analyze, analyzeManyToMany, - resolve, - open + resolve } = Wappalyzer -const { agent, promisify, getOption, setOption } = Utils +const { agent, promisify, getOption, setOption, open } = Utils const expiry = 1000 * 60 * 60 * 24 @@ -21,12 +20,9 @@ const Driver = { * Initialise driver */ async init() { - // Enable messaging between scripts - chrome.runtime.onConnect.addListener(Driver.onRuntimeConnect) - await Driver.loadTechnologies() - const hostnameCache = (await getOption('hostnames')) || {} + const hostnameCache = await getOption('hostnames', {}) Driver.cache = { hostnames: Object.keys(hostnameCache).reduce( @@ -55,8 +51,8 @@ const Driver = { {} ), tabs: {}, - robots: (await getOption('robots')) || {}, - ads: (await getOption('ads')) || [] + robots: await getOption('robots', {}), + ads: await getOption('ads', []) } chrome.webRequest.onCompleted.addListener( @@ -66,6 +62,9 @@ const Driver = { ) 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 previous = await getOption('version') const upgradeMessage = await getOption('upgradeMessage', true)