Fix browser is undefined error in content.js

main
Elbert Alias 7 years ago
parent 7118649fb0
commit a05d78e47d

@ -1,19 +1,19 @@
/** global: browser */ /** global: browser */
if ( document.body !== undefined ) { if ( typeof browser !== 'undefined' && typeof document.body !== 'undefined' ) {
var html = document.documentElement.outerHTML; var html = document.documentElement.outerHTML;
if ( html.length > 50000 ) { if ( html.length > 50000 ) {
html = html.substring(0, 25000) + html.substring(html.length - 25000, html.length); html = html.substring(0, 25000) + html.substring(html.length - 25000, html.length);
} }
try {
browser.runtime.sendMessage({ browser.runtime.sendMessage({
id: 'analyze', id: 'analyze',
subject: { html }, subject: { html },
source: 'content.js' source: 'content.js'
}); });
try {
var container = document.createElement('wappalyzerData'); var container = document.createElement('wappalyzerData');
container.setAttribute('id', 'wappalyzerData'); container.setAttribute('id', 'wappalyzerData');
@ -42,7 +42,7 @@ if ( document.body !== undefined ) {
document.documentElement.appendChild(container); document.documentElement.appendChild(container);
document.documentElement.appendChild(script); document.documentElement.appendChild(script);
} catch(e) { } catch(e) {
log('Error: ' + e); log(e);
} }
} }

Loading…
Cancel
Save