This commit is contained in:
gorhill 2017-07-23 09:56:43 -04:00
parent 48ee02980b
commit 0d892a8856
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 7 additions and 2 deletions

View File

@ -167,6 +167,10 @@ var cosmeticFiltersActivated = function() {
// Probably no longer need to watch for style tags removal/tampering with fix // Probably no longer need to watch for style tags removal/tampering with fix
// to https://github.com/gorhill/uBlock/issues/963 // to https://github.com/gorhill/uBlock/issues/963
// https://github.com/gorhill/uBlock/issues/2810
// With Firefox Nightly, it may happens style tags are injected before the
// head element is present.
var platformUserCSS = (function() { var platformUserCSS = (function() {
if ( vAPI.userCSS instanceof Object ) { if ( vAPI.userCSS instanceof Object ) {
return vAPI.userCSS; return vAPI.userCSS;
@ -179,8 +183,9 @@ var platformUserCSS = (function() {
var style = document.createElement('style'); var style = document.createElement('style');
style.setAttribute('type', 'text/css'); style.setAttribute('type', 'text/css');
style.textContent = css; style.textContent = css;
if ( document.head ) { var parent = document.head || document.documentElement;
document.head.appendChild(style); if ( parent !== null ) {
parent.appendChild(style);
} }
this.styles.push(style); this.styles.push(style);
if ( style.sheet ) { if ( style.sheet ) {