From 535a46db37017e9b3a8b0c675702c1f1da3b1ad6 Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 12 May 2015 08:04:13 -0400 Subject: [PATCH] this fixes warning/error entries in browser console --- src/js/contentscript-end.js | 7 ++++++- src/js/contentscript-start.js | 5 +++++ src/js/start.js | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 38a9dd2..836dcbc 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -36,7 +36,12 @@ // https://github.com/chrisaljoudi/uBlock/issues/464 if ( document instanceof HTMLDocument === false ) { //console.debug('contentscript-end.js > not a HTLMDocument'); - return false; + return; +} + +// This can also happen (for example if script injected into a `data:` URI doc) +if ( !window.location ) { + return; } // This can happen diff --git a/src/js/contentscript-start.js b/src/js/contentscript-start.js index e91aabd..ba756c8 100644 --- a/src/js/contentscript-start.js +++ b/src/js/contentscript-start.js @@ -38,6 +38,11 @@ if ( document instanceof HTMLDocument === false ) { return; } +// This can also happen (for example if script injected into a `data:` URI doc) +if ( !window.location ) { + return; +} + // This can happen if ( !vAPI ) { //console.debug('contentscript-start.js > vAPI not found'); diff --git a/src/js/start.js b/src/js/start.js index d4e8286..3052c95 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -57,7 +57,9 @@ var defaultLocalUserSettings = { ].join(''), placeholderBorder: '1px solid rgba(0, 0, 0, 0.05)', placeholderDocument: [ - '