1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-14 23:12:28 +02:00

Ignore compilation hints when applying exception cosmetic filters

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2475
This commit is contained in:
Raymond Hill 2023-02-01 11:24:07 -05:00
parent 6eec497ae8
commit bc19a93815
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 18 additions and 14 deletions

View File

@ -682,8 +682,7 @@ FilterContainer.prototype.disableSurveyor = function(details) {
/******************************************************************************/
FilterContainer.prototype.cssRuleFromProcedural = function(json) {
const pfilter = JSON.parse(json);
FilterContainer.prototype.cssRuleFromProcedural = function(pfilter) {
if ( pfilter.cssable !== true ) { return; }
const { tasks, action } = pfilter;
let mq;
@ -839,15 +838,13 @@ FilterContainer.prototype.retrieveSpecificSelectors = function(
2
);
// Apply exceptions to specific filterset
if ( exceptionSet.size !== 0 ) {
out.exceptionFilters = Array.from(exceptionSet);
for ( const exception of exceptionSet ) {
if (
specificSet.delete(exception) ||
proceduralSet.delete(exception)
) {
out.exceptedFilters.push(exception);
}
for ( const selector of specificSet ) {
if ( exceptionSet.has(selector) === false ) { continue; }
specificSet.delete(selector);
out.exceptedFilters.push(selector);
}
}
@ -857,11 +854,18 @@ FilterContainer.prototype.retrieveSpecificSelectors = function(
);
}
// Some procedural filters are really declarative cosmetic filters, so
// we extract and inject them immediately.
// Apply exceptions to procedural filterset.
// Also, some procedural filters are really declarative cosmetic
// filters, so we extract and inject them immediately.
if ( proceduralSet.size !== 0 ) {
for ( const json of proceduralSet ) {
const cssRule = this.cssRuleFromProcedural(json);
const pfilter = JSON.parse(json);
if ( exceptionSet.has(pfilter.raw) ) {
proceduralSet.delete(json);
out.exceptedFilters.push(pfilter.raw);
continue;
}
const cssRule = this.cssRuleFromProcedural(pfilter);
if ( cssRule === undefined ) { continue; }
injectedCSS.push(cssRule);
proceduralSet.delete(json);

View File

@ -2982,7 +2982,7 @@ class ExtSelectorCompiler {
if ( hasArgs ) {
const arg = this.astSerialize(part.args);
if ( typeof arg !== 'string' ) { return; }
out.push(`(${arg})`);
out.push(`(${arg.trim()})`);
}
break;
}
@ -3101,7 +3101,7 @@ class ExtSelectorCompiler {
}
if ( tasks.length === 0 && out.action === undefined ) {
if ( prelude.length === 0 ) { return; }
return prelude.join('');
return prelude.join('').trim();
}
if ( prelude.length !== 0 ) {
tasks.push(this.createSpathTask(prelude.join('')));