Skip to content

Commit 94a1d72

Browse files
committed
uBlock-LLC/uBlock#1528: apply fix to scriptlets too
1 parent 1a380f0 commit 94a1d72

7 files changed

Lines changed: 49 additions & 15 deletions

File tree

src/js/contentscript-end.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Home: https://github.com/gorhill/uBlock
2020
*/
2121

22-
/* global vAPI, HTMLDocument */
22+
/* global vAPI, HTMLDocument, XMLDocument */
2323

2424
/******************************************************************************/
2525

@@ -34,6 +34,7 @@
3434
// https://github.com/chrisaljoudi/uBlock/issues/464
3535
if ( document instanceof HTMLDocument === false ) {
3636
// https://github.com/chrisaljoudi/uBlock/issues/1528
37+
// A XMLDocument can be a valid HTML document.
3738
if (
3839
document instanceof XMLDocument === false ||
3940
document.createElement('div') instanceof HTMLDivElement === false

src/js/contentscript-start.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121

2222
/* jshint multistr: true */
23-
/* global vAPI, HTMLDocument */
23+
/* global vAPI, HTMLDocument, XMLDocument */
2424

2525
/******************************************************************************/
2626

@@ -37,6 +37,7 @@
3737
// https://github.com/chrisaljoudi/uBlock/issues/464
3838
if ( document instanceof HTMLDocument === false ) {
3939
// https://github.com/chrisaljoudi/uBlock/issues/1528
40+
// A XMLDocument can be a valid HTML document.
4041
if (
4142
document instanceof XMLDocument === false ||
4243
document.createElement('div') instanceof HTMLDivElement === false

src/js/scriptlets/cosmetic-logger.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Home: https://github.com/gorhill/uBlock
2020
*/
2121

22-
/* global vAPI, HTMLDocument */
22+
/* global vAPI, HTMLDocument, XMLDocument */
2323

2424
/******************************************************************************/
2525

@@ -31,7 +31,14 @@
3131

3232
// https://github.com/gorhill/uBlock/issues/464
3333
if ( document instanceof HTMLDocument === false ) {
34-
return;
34+
// https://github.com/chrisaljoudi/uBlock/issues/1528
35+
// A XMLDocument can be a valid HTML document.
36+
if (
37+
document instanceof XMLDocument === false ||
38+
document.createElement('div') instanceof HTMLDivElement === false
39+
) {
40+
return;
41+
}
3542
}
3643

3744
// This can happen

src/js/scriptlets/cosmetic-off.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Home: https://github.com/gorhill/uBlock
2020
*/
2121

22-
/* global vAPI, HTMLDocument */
22+
/* global vAPI, HTMLDocument, XMLDocument */
2323

2424
/******************************************************************************/
2525

@@ -31,8 +31,14 @@
3131

3232
// https://github.com/gorhill/uBlock/issues/464
3333
if ( document instanceof HTMLDocument === false ) {
34-
//console.debug('cosmetic-off.js > not a HTLMDocument');
35-
return;
34+
// https://github.com/chrisaljoudi/uBlock/issues/1528
35+
// A XMLDocument can be a valid HTML document.
36+
if (
37+
document instanceof XMLDocument === false ||
38+
document.createElement('div') instanceof HTMLDivElement === false
39+
) {
40+
return;
41+
}
3642
}
3743

3844
// This can happen

src/js/scriptlets/cosmetic-on.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Home: https://github.com/gorhill/uBlock
2020
*/
2121

22-
/* global vAPI, HTMLDocument */
22+
/* global vAPI, HTMLDocument, XMLDocument */
2323

2424
/******************************************************************************/
2525

@@ -31,8 +31,14 @@
3131

3232
// https://github.com/gorhill/uBlock/issues/464
3333
if ( document instanceof HTMLDocument === false ) {
34-
//console.debug('cosmetic-on.js > not a HTLMDocument');
35-
return;
34+
// https://github.com/chrisaljoudi/uBlock/issues/1528
35+
// A XMLDocument can be a valid HTML document.
36+
if (
37+
document instanceof XMLDocument === false ||
38+
document.createElement('div') instanceof HTMLDivElement === false
39+
) {
40+
return;
41+
}
3642
}
3743

3844
// This can happen

src/js/scriptlets/cosmetic-survey.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Home: https://github.com/gorhill/uBlock
2020
*/
2121

22-
/* global vAPI, HTMLDocument */
22+
/* global vAPI, HTMLDocument, XMLDocument */
2323

2424
/******************************************************************************/
2525

@@ -31,8 +31,14 @@
3131

3232
// https://github.com/gorhill/uBlock/issues/464
3333
if ( document instanceof HTMLDocument === false ) {
34-
//console.debug('cosmetic-survey.js > not a HTLMDocument');
35-
return;
34+
// https://github.com/chrisaljoudi/uBlock/issues/1528
35+
// A XMLDocument can be a valid HTML document.
36+
if (
37+
document instanceof XMLDocument === false ||
38+
document.createElement('div') instanceof HTMLDivElement === false
39+
) {
40+
return;
41+
}
3642
}
3743

3844
// This can happen

src/js/scriptlets/dom-inspector.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Home: https://github.com/gorhill/uBlock
2020
*/
2121

22-
/* global vAPI, HTMLDocument */
22+
/* global vAPI, HTMLDocument, XMLDocument */
2323

2424
/******************************************************************************/
2525
/******************************************************************************/
@@ -32,7 +32,14 @@
3232

3333
// https://github.com/gorhill/uBlock/issues/464
3434
if ( document instanceof HTMLDocument === false ) {
35-
return;
35+
// https://github.com/chrisaljoudi/uBlock/issues/1528
36+
// A XMLDocument can be a valid HTML document.
37+
if (
38+
document instanceof XMLDocument === false ||
39+
document.createElement('div') instanceof HTMLDivElement === false
40+
) {
41+
return;
42+
}
3643
}
3744

3845
// This can happen

0 commit comments

Comments
 (0)