From a05d78e47d6eeb4c8046a03f437bb38baed3cc8a Mon Sep 17 00:00:00 2001 From: Elbert Alias Date: Sat, 2 Sep 2017 14:05:03 +1000 Subject: [PATCH] Fix browser is undefined error in content.js --- src/drivers/webextension/js/content.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/drivers/webextension/js/content.js b/src/drivers/webextension/js/content.js index 2255119e1..c4e1940b0 100644 --- a/src/drivers/webextension/js/content.js +++ b/src/drivers/webextension/js/content.js @@ -1,19 +1,19 @@ /** global: browser */ -if ( document.body !== undefined ) { +if ( typeof browser !== 'undefined' && typeof document.body !== 'undefined' ) { var html = document.documentElement.outerHTML; if ( html.length > 50000 ) { html = html.substring(0, 25000) + html.substring(html.length - 25000, html.length); } - browser.runtime.sendMessage({ - id: 'analyze', - subject: { html }, - source: 'content.js' - }); - try { + browser.runtime.sendMessage({ + id: 'analyze', + subject: { html }, + source: 'content.js' + }); + var container = document.createElement('wappalyzerData'); container.setAttribute('id', 'wappalyzerData'); @@ -42,7 +42,7 @@ if ( document.body !== undefined ) { document.documentElement.appendChild(container); document.documentElement.appendChild(script); } catch(e) { - log('Error: ' + e); + log(e); } }