From cd0b1b6e60ce3fc99b5c0ec8916129de006cbe66 Mon Sep 17 00:00:00 2001 From: Elbert Alias <77259+AliasIO@users.noreply.github.com> Date: Fri, 29 Jun 2018 14:11:35 +1000 Subject: [PATCH] Fix Srutinizer issues --- src/drivers/webextension/js/inject.js | 40 +++++++++++++-------------- src/drivers/webextension/js/popup.js | 2 +- src/wappalyzer.js | 4 +-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/drivers/webextension/js/inject.js b/src/drivers/webextension/js/inject.js index 6c0cc60a1..7871cf76b 100644 --- a/src/drivers/webextension/js/inject.js +++ b/src/drivers/webextension/js/inject.js @@ -1,6 +1,24 @@ (() => { try { - addEventListener('message', onMessage); + const detectJs = chain => { + const properties = chain.split('.'); + + let value = properties.length ? window : null; + + for ( let i = 0; i < properties.length; i ++ ) { + let property = properties[i]; + + if ( value && value.hasOwnProperty(property) ) { + value = value[property]; + } else { + value = null; + + break; + } + } + + return typeof value === 'string' || typeof value === 'number' ? value : !!value; + }; const onMessage = event => { if ( event.data.id !== 'patterns' ) { @@ -36,25 +54,7 @@ postMessage({ id: 'js', js }, '*'); }; - const detectJs = chain => { - const properties = chain.split('.'); - - let value = properties.length ? window : null; - - for ( let i = 0; i < properties.length; i ++ ) { - let property = properties[i]; - - if ( value && value.hasOwnProperty(property) ) { - value = value[property]; - } else { - value = null; - - break; - } - } - - return typeof value === 'string' || typeof value === 'number' ? value : !!value; - }; + addEventListener('message', onMessage); } catch(e) { // Fail quietly } diff --git a/src/drivers/webextension/js/popup.js b/src/drivers/webextension/js/popup.js index 25b30afaf..6483a9b14 100644 --- a/src/drivers/webextension/js/popup.js +++ b/src/drivers/webextension/js/popup.js @@ -91,7 +91,7 @@ function appsToDomTemplate(response) { for ( let cat in categories ) { const apps = []; - for ( appName in categories[cat].apps ) { + for ( let appName in categories[cat].apps ) { let confidence = response.tabCache.detected[appName].confidenceTotal; let version = response.tabCache.detected[appName].version; diff --git a/src/wappalyzer.js b/src/wappalyzer.js index 028a254fe..cfa3b2583 100644 --- a/src/wappalyzer.js +++ b/src/wappalyzer.js @@ -123,7 +123,7 @@ class Wappalyzer { this.driver.displayApps(this.detected[url.canonical], { language }, context); - resolve(); + return resolve(); }); }); } @@ -152,7 +152,7 @@ class Wappalyzer { return reject(); } - resolve(); + return resolve(); }, () => resolve()); }); };