From 94a1d72fc8ee3d73347b9eaea30ce0ca396bbb3e Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 28 Aug 2015 10:44:33 -0400 Subject: [PATCH] https://github.com/chrisaljoudi/uBlock/issues/1528: apply fix to scriptlets too --- src/js/contentscript-end.js | 3 ++- src/js/contentscript-start.js | 3 ++- src/js/scriptlets/cosmetic-logger.js | 11 +++++++++-- src/js/scriptlets/cosmetic-off.js | 12 +++++++++--- src/js/scriptlets/cosmetic-on.js | 12 +++++++++--- src/js/scriptlets/cosmetic-survey.js | 12 +++++++++--- src/js/scriptlets/dom-inspector.js | 11 +++++++++-- 7 files changed, 49 insertions(+), 15 deletions(-) diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 9e3e1a291..bceb85645 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* global vAPI, HTMLDocument */ +/* global vAPI, HTMLDocument, XMLDocument */ /******************************************************************************/ @@ -34,6 +34,7 @@ // https://github.com/chrisaljoudi/uBlock/issues/464 if ( document instanceof HTMLDocument === false ) { // https://github.com/chrisaljoudi/uBlock/issues/1528 + // A XMLDocument can be a valid HTML document. if ( document instanceof XMLDocument === false || document.createElement('div') instanceof HTMLDivElement === false diff --git a/src/js/contentscript-start.js b/src/js/contentscript-start.js index 21931a3e1..ac7d9247a 100644 --- a/src/js/contentscript-start.js +++ b/src/js/contentscript-start.js @@ -20,7 +20,7 @@ */ /* jshint multistr: true */ -/* global vAPI, HTMLDocument */ +/* global vAPI, HTMLDocument, XMLDocument */ /******************************************************************************/ @@ -37,6 +37,7 @@ // https://github.com/chrisaljoudi/uBlock/issues/464 if ( document instanceof HTMLDocument === false ) { // https://github.com/chrisaljoudi/uBlock/issues/1528 + // A XMLDocument can be a valid HTML document. if ( document instanceof XMLDocument === false || document.createElement('div') instanceof HTMLDivElement === false diff --git a/src/js/scriptlets/cosmetic-logger.js b/src/js/scriptlets/cosmetic-logger.js index bd323768d..0b7c6736f 100644 --- a/src/js/scriptlets/cosmetic-logger.js +++ b/src/js/scriptlets/cosmetic-logger.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* global vAPI, HTMLDocument */ +/* global vAPI, HTMLDocument, XMLDocument */ /******************************************************************************/ @@ -31,7 +31,14 @@ // https://github.com/gorhill/uBlock/issues/464 if ( document instanceof HTMLDocument === false ) { - return; + // https://github.com/chrisaljoudi/uBlock/issues/1528 + // A XMLDocument can be a valid HTML document. + if ( + document instanceof XMLDocument === false || + document.createElement('div') instanceof HTMLDivElement === false + ) { + return; + } } // This can happen diff --git a/src/js/scriptlets/cosmetic-off.js b/src/js/scriptlets/cosmetic-off.js index e8d46eb11..4079269ed 100644 --- a/src/js/scriptlets/cosmetic-off.js +++ b/src/js/scriptlets/cosmetic-off.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* global vAPI, HTMLDocument */ +/* global vAPI, HTMLDocument, XMLDocument */ /******************************************************************************/ @@ -31,8 +31,14 @@ // https://github.com/gorhill/uBlock/issues/464 if ( document instanceof HTMLDocument === false ) { - //console.debug('cosmetic-off.js > not a HTLMDocument'); - return; + // https://github.com/chrisaljoudi/uBlock/issues/1528 + // A XMLDocument can be a valid HTML document. + if ( + document instanceof XMLDocument === false || + document.createElement('div') instanceof HTMLDivElement === false + ) { + return; + } } // This can happen diff --git a/src/js/scriptlets/cosmetic-on.js b/src/js/scriptlets/cosmetic-on.js index e53397f07..2c9472189 100644 --- a/src/js/scriptlets/cosmetic-on.js +++ b/src/js/scriptlets/cosmetic-on.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* global vAPI, HTMLDocument */ +/* global vAPI, HTMLDocument, XMLDocument */ /******************************************************************************/ @@ -31,8 +31,14 @@ // https://github.com/gorhill/uBlock/issues/464 if ( document instanceof HTMLDocument === false ) { - //console.debug('cosmetic-on.js > not a HTLMDocument'); - return; + // https://github.com/chrisaljoudi/uBlock/issues/1528 + // A XMLDocument can be a valid HTML document. + if ( + document instanceof XMLDocument === false || + document.createElement('div') instanceof HTMLDivElement === false + ) { + return; + } } // This can happen diff --git a/src/js/scriptlets/cosmetic-survey.js b/src/js/scriptlets/cosmetic-survey.js index f3e0890f8..39e71052c 100644 --- a/src/js/scriptlets/cosmetic-survey.js +++ b/src/js/scriptlets/cosmetic-survey.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* global vAPI, HTMLDocument */ +/* global vAPI, HTMLDocument, XMLDocument */ /******************************************************************************/ @@ -31,8 +31,14 @@ // https://github.com/gorhill/uBlock/issues/464 if ( document instanceof HTMLDocument === false ) { - //console.debug('cosmetic-survey.js > not a HTLMDocument'); - return; + // https://github.com/chrisaljoudi/uBlock/issues/1528 + // A XMLDocument can be a valid HTML document. + if ( + document instanceof XMLDocument === false || + document.createElement('div') instanceof HTMLDivElement === false + ) { + return; + } } // This can happen diff --git a/src/js/scriptlets/dom-inspector.js b/src/js/scriptlets/dom-inspector.js index 203ba0ddb..5a42a0e79 100644 --- a/src/js/scriptlets/dom-inspector.js +++ b/src/js/scriptlets/dom-inspector.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* global vAPI, HTMLDocument */ +/* global vAPI, HTMLDocument, XMLDocument */ /******************************************************************************/ /******************************************************************************/ @@ -32,7 +32,14 @@ // https://github.com/gorhill/uBlock/issues/464 if ( document instanceof HTMLDocument === false ) { - return; + // https://github.com/chrisaljoudi/uBlock/issues/1528 + // A XMLDocument can be a valid HTML document. + if ( + document instanceof XMLDocument === false || + document.createElement('div') instanceof HTMLDivElement === false + ) { + return; + } } // This can happen