mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-13 02:14:17 +01:00
Fix broken styling of selectors with pseudo elements
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/382 Additionally, fix minor parsing issues with AdGuard's cosmetic filters.
This commit is contained in:
parent
601ec67ab6
commit
328d6a09f4
2 changed files with 7 additions and 6 deletions
|
@ -777,11 +777,6 @@ vAPI.injectScriptlet = function(doc, text) {
|
||||||
for ( const raw of selectors ) {
|
for ( const raw of selectors ) {
|
||||||
if ( this.selectors.has(raw) ) { continue; }
|
if ( this.selectors.has(raw) ) { continue; }
|
||||||
const o = JSON.parse(raw);
|
const o = JSON.parse(raw);
|
||||||
if ( o.pseudo !== undefined ) {
|
|
||||||
this.domFilterer.addCSSRule(o.selector, vAPI.hideStyle);
|
|
||||||
mustCommit = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// CSS selector-based styles.
|
// CSS selector-based styles.
|
||||||
if (
|
if (
|
||||||
o.action !== undefined &&
|
o.action !== undefined &&
|
||||||
|
@ -792,6 +787,11 @@ vAPI.injectScriptlet = function(doc, text) {
|
||||||
mustCommit = true;
|
mustCommit = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ( o.pseudo !== undefined ) {
|
||||||
|
this.domFilterer.addCSSRule(o.selector, vAPI.hideStyle);
|
||||||
|
mustCommit = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let style, styleToken;
|
let style, styleToken;
|
||||||
if ( o.action === undefined ) {
|
if ( o.action === undefined ) {
|
||||||
style = vAPI.hideStyle;
|
style = vAPI.hideStyle;
|
||||||
|
|
|
@ -1215,6 +1215,7 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
if ( hasBits(this.parser.flavorBits, BITFlavorExtStyle) ) {
|
if ( hasBits(this.parser.flavorBits, BITFlavorExtStyle) ) {
|
||||||
raw = this.translateAdguardCSSInjectionFilter(raw);
|
raw = this.translateAdguardCSSInjectionFilter(raw);
|
||||||
if ( raw === '' ) { return false; }
|
if ( raw === '' ) { return false; }
|
||||||
|
this.parser.flavorBits &= ~BITFlavorExtStyle;
|
||||||
out.raw = raw;
|
out.raw = raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1264,7 +1265,7 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
}
|
}
|
||||||
|
|
||||||
translateAdguardCSSInjectionFilter(suffix) {
|
translateAdguardCSSInjectionFilter(suffix) {
|
||||||
const matches = /^([^{]+)\{([^}]+)\}\s*$/.exec(suffix);
|
const matches = /^(.*)\s*\{([^}]+)\}\s*$/.exec(suffix);
|
||||||
if ( matches === null ) { return ''; }
|
if ( matches === null ) { return ''; }
|
||||||
const selector = matches[1].trim();
|
const selector = matches[1].trim();
|
||||||
const style = matches[2].trim();
|
const style = matches[2].trim();
|
||||||
|
|
Loading…
Reference in a new issue