mirror of https://github.com/gorhill/uBlock.git
fix #3321: make uBO the bigger person and walk away from a pointless fight
This commit is contained in:
parent
e7d5c836d9
commit
88ce17561f
|
@ -34,6 +34,7 @@ if ( typeof vAPI === 'object' ) { // >>>>>>>> start of HUGE-IF-BLOCK
|
||||||
|
|
||||||
vAPI.userStylesheet = {
|
vAPI.userStylesheet = {
|
||||||
style: null,
|
style: null,
|
||||||
|
styleFixCount: 0,
|
||||||
css: new Map(),
|
css: new Map(),
|
||||||
disabled: false,
|
disabled: false,
|
||||||
apply: function() {
|
apply: function() {
|
||||||
|
@ -47,7 +48,12 @@ vAPI.userStylesheet = {
|
||||||
var observer = new MutationObserver(function() {
|
var observer = new MutationObserver(function() {
|
||||||
if ( this.style === null ) { return; }
|
if ( this.style === null ) { return; }
|
||||||
if ( this.style.sheet !== null ) { return; }
|
if ( this.style.sheet !== null ) { return; }
|
||||||
|
this.styleFixCount += 1;
|
||||||
|
if ( this.styleFixCount < 32 ) {
|
||||||
parent.appendChild(this.style);
|
parent.appendChild(this.style);
|
||||||
|
} else {
|
||||||
|
observer.disconnect();
|
||||||
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
observer.observe(parent, { childList: true });
|
observer.observe(parent, { childList: true });
|
||||||
},
|
},
|
||||||
|
@ -66,11 +72,13 @@ vAPI.userStylesheet = {
|
||||||
if ( cssRule === undefined ) { return; }
|
if ( cssRule === undefined ) { return; }
|
||||||
this.css.delete(cssText);
|
this.css.delete(cssText);
|
||||||
if ( this.style === null ) { return; }
|
if ( this.style === null ) { return; }
|
||||||
var rules = this.style.sheet.cssRules,
|
var sheet = this.style.sheet;
|
||||||
|
if ( !sheet ) { return; }
|
||||||
|
var rules = sheet.cssRules,
|
||||||
i = rules.length;
|
i = rules.length;
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
if ( rules[i] !== cssRule ) { continue; }
|
if ( rules[i] !== cssRule ) { continue; }
|
||||||
this.style.sheet.deleteRule(i);
|
sheet.deleteRule(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( rules.length !== 0 ) { return; }
|
if ( rules.length !== 0 ) { return; }
|
||||||
|
|
Loading…
Reference in New Issue