mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-06 19:02:30 +01:00
fix #2448
This commit is contained in:
parent
fba8ea2e75
commit
cf123b9264
@ -531,12 +531,7 @@ var domFilterer = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
styleSelectors: { // Style filters
|
nqsSelectors: [], // Non-querySelector-able filters
|
||||||
entries: [],
|
|
||||||
add: function(o) {
|
|
||||||
this.entries.push(o);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
proceduralSelectors: { // Hiding filters: procedural
|
proceduralSelectors: { // Hiding filters: procedural
|
||||||
entries: [],
|
entries: [],
|
||||||
add: function(o) {
|
add: function(o) {
|
||||||
@ -578,7 +573,12 @@ var domFilterer = {
|
|||||||
var o = JSON.parse(selector);
|
var o = JSON.parse(selector);
|
||||||
if ( o.style ) {
|
if ( o.style ) {
|
||||||
this.newStyleRuleBuffer.push(o.style.join(' '));
|
this.newStyleRuleBuffer.push(o.style.join(' '));
|
||||||
this.styleSelectors.add(o);
|
this.nqsSelectors.push(o.raw);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( o.pseudoclass ) {
|
||||||
|
this.newHideSelectorBuffer.push(o.raw);
|
||||||
|
this.nqsSelectors.push(o.raw);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( o.tasks ) {
|
if ( o.tasks ) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
uBlock Origin - a browser extension to block requests.
|
uBlock Origin - a browser extension to block requests.
|
||||||
Copyright (C) 2014-2016 Raymond Hill
|
Copyright (C) 2014-2017 Raymond Hill
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -732,7 +732,8 @@ FilterContainer.prototype.freeze = function() {
|
|||||||
// https://github.com/gorhill/uBlock/issues/1752
|
// https://github.com/gorhill/uBlock/issues/1752
|
||||||
|
|
||||||
FilterContainer.prototype.compileSelector = (function() {
|
FilterContainer.prototype.compileSelector = (function() {
|
||||||
var reStyleSelector = /^(.+?):style\((.+?)\)$/,
|
var reAfterBeforeSelector = /^(.+?)(::?after|::?before)$/,
|
||||||
|
reStyleSelector = /^(.+?):style\((.+?)\)$/,
|
||||||
reStyleBad = /url\([^)]+\)/,
|
reStyleBad = /url\([^)]+\)/,
|
||||||
reScriptSelector = /^script:(contains|inject)\((.+)\)$/,
|
reScriptSelector = /^script:(contains|inject)\((.+)\)$/,
|
||||||
div = document.createElement('div');
|
div = document.createElement('div');
|
||||||
@ -751,17 +752,43 @@ FilterContainer.prototype.compileSelector = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We rarely reach this point.
|
// We rarely reach this point.
|
||||||
var matches;
|
var matches,
|
||||||
|
selector = raw,
|
||||||
|
pseudoclass,
|
||||||
|
style;
|
||||||
|
|
||||||
// `:style` selector?
|
// `:style` selector?
|
||||||
if (
|
if ( (matches = reStyleSelector.exec(selector)) !== null ) {
|
||||||
(matches = reStyleSelector.exec(raw)) !== null &&
|
selector = matches[1];
|
||||||
isValidCSSSelector(matches[1]) &&
|
style = matches[2];
|
||||||
isValidStyleProperty(matches[2])
|
}
|
||||||
) {
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/2448
|
||||||
|
// :after- or :before-based selector?
|
||||||
|
if ( (matches = reAfterBeforeSelector.exec(selector)) ) {
|
||||||
|
selector = matches[1];
|
||||||
|
pseudoclass = matches[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( style !== undefined || pseudoclass !== undefined ) {
|
||||||
|
if ( isValidCSSSelector(selector) === false ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( pseudoclass !== undefined ) {
|
||||||
|
selector += pseudoclass;
|
||||||
|
}
|
||||||
|
if ( style !== undefined ) {
|
||||||
|
if ( isValidStyleProperty(style) === false ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
raw: raw,
|
raw: raw,
|
||||||
style: [ matches[1], '{' + matches[2] + '}' ]
|
style: [ selector, '{' + style + '}' ]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return JSON.stringify({
|
||||||
|
raw: raw,
|
||||||
|
pseudoclass: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
uBlock Origin - a browser extension to block requests.
|
uBlock Origin - a browser extension to block requests.
|
||||||
Copyright (C) 2015-2016 Raymond Hill
|
Copyright (C) 2015-2017 Raymond Hill
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -51,14 +51,11 @@ vAPI.domFilterer.simpleHideSelectors.entries.forEach(evaluateSelector);
|
|||||||
// Complex CSS selector-based cosmetic filters.
|
// Complex CSS selector-based cosmetic filters.
|
||||||
vAPI.domFilterer.complexHideSelectors.entries.forEach(evaluateSelector);
|
vAPI.domFilterer.complexHideSelectors.entries.forEach(evaluateSelector);
|
||||||
|
|
||||||
// Style cosmetic filters.
|
// Non-querySelector-able filters.
|
||||||
vAPI.domFilterer.styleSelectors.entries.forEach(function(filter) {
|
vAPI.domFilterer.nqsSelectors.forEach(function(filter) {
|
||||||
if (
|
if ( loggedSelectors.hasOwnProperty(filter) === false ) {
|
||||||
loggedSelectors.hasOwnProperty(filter.raw) === false &&
|
loggedSelectors[filter] = true;
|
||||||
document.querySelector(filter.style[0]) !== null
|
matchedSelectors.push(filter);
|
||||||
) {
|
|
||||||
loggedSelectors[filter.raw] = true;
|
|
||||||
matchedSelectors.push(filter.raw);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user