mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-04 10:09:38 +02:00
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() {
|
||||
var doc = document,
|
||||
html = doc.documentElement,
|
||||
@ -422,16 +435,7 @@ var domFilterer = {
|
||||
}
|
||||
|
||||
if ( styleText !== '' ) {
|
||||
var styleTag = document.createElement('style');
|
||||
styleTag.setAttribute('type', 'text/css');
|
||||
styleTag.textContent = styleText;
|
||||
if ( document.head ) {
|
||||
document.head.appendChild(styleTag);
|
||||
}
|
||||
this.styleTags.push(styleTag);
|
||||
if ( userCSS ) {
|
||||
userCSS.add(styleText);
|
||||
}
|
||||
this.addStyleTag(styleText);
|
||||
}
|
||||
|
||||
// Simple selectors: incremental.
|
||||
@ -462,8 +466,15 @@ var domFilterer = {
|
||||
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;
|
||||
if ( commitHit ) {
|
||||
if ( beforeHiddenNodeCount === 0 ) {
|
||||
this.addStyleTag(':root *[' + this.hiddenId + '][hidden] { display: none !important; }');
|
||||
}
|
||||
this.addedNodesHandlerMissCount = 0;
|
||||
} else {
|
||||
this.addedNodesHandlerMissCount += 1;
|
||||
|
Loading…
Reference in New Issue
Block a user