mirror of https://github.com/gorhill/uBlock.git
fix #1912
This commit is contained in:
parent
b30648dd47
commit
0a15a95ad9
|
@ -366,6 +366,19 @@ var domFilterer = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addStyleTag: function(text) {
|
||||||
|
var styleTag = document.createElement('style');
|
||||||
|
styleTag.setAttribute('type', 'text/css');
|
||||||
|
styleTag.textContent = text;
|
||||||
|
if ( document.head ) {
|
||||||
|
document.head.appendChild(styleTag);
|
||||||
|
}
|
||||||
|
this.styleTags.push(styleTag);
|
||||||
|
if ( userCSS ) {
|
||||||
|
userCSS.add(text);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
checkStyleTags_: function() {
|
checkStyleTags_: function() {
|
||||||
var doc = document,
|
var doc = document,
|
||||||
html = doc.documentElement,
|
html = doc.documentElement,
|
||||||
|
@ -422,16 +435,7 @@ var domFilterer = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( styleText !== '' ) {
|
if ( styleText !== '' ) {
|
||||||
var styleTag = document.createElement('style');
|
this.addStyleTag(styleText);
|
||||||
styleTag.setAttribute('type', 'text/css');
|
|
||||||
styleTag.textContent = styleText;
|
|
||||||
if ( document.head ) {
|
|
||||||
document.head.appendChild(styleTag);
|
|
||||||
}
|
|
||||||
this.styleTags.push(styleTag);
|
|
||||||
if ( userCSS ) {
|
|
||||||
userCSS.add(styleText);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple selectors: incremental.
|
// Simple selectors: incremental.
|
||||||
|
@ -462,8 +466,15 @@ var domFilterer = {
|
||||||
this.runJob(this.jobQueue[i], complexHideNode);
|
this.runJob(this.jobQueue[i], complexHideNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/1912
|
||||||
|
// If one or more nodes have been manually hidden, insert a style tag
|
||||||
|
// targeting these manually hidden nodes. For browsers supporting
|
||||||
|
// user styles, this allows uBO to win.
|
||||||
var commitHit = this.hiddenNodeCount !== beforeHiddenNodeCount;
|
var commitHit = this.hiddenNodeCount !== beforeHiddenNodeCount;
|
||||||
if ( commitHit ) {
|
if ( commitHit ) {
|
||||||
|
if ( beforeHiddenNodeCount === 0 ) {
|
||||||
|
this.addStyleTag(':root *[' + this.hiddenId + '][hidden] { display: none !important; }');
|
||||||
|
}
|
||||||
this.addedNodesHandlerMissCount = 0;
|
this.addedNodesHandlerMissCount = 0;
|
||||||
} else {
|
} else {
|
||||||
this.addedNodesHandlerMissCount += 1;
|
this.addedNodesHandlerMissCount += 1;
|
||||||
|
|
Loading…
Reference in New Issue