Skip to content

Commit

Permalink
Ignore compilation hints when applying exception cosmetic filters
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Feb 1, 2023
1 parent 6eec497 commit bc19a93
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
28 changes: 16 additions & 12 deletions src/js/cosmetic-filtering.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/js/static-filtering-parser.js
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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('')));
Expand Down

2 comments on commit bc19a93

@uBlock-user
Copy link
Contributor

@uBlock-user uBlock-user commented on bc19a93 Feb 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exceptor doesn't work for :remove() filters with b16 build onwards.

STR --

  • Add www.google.com##.L3eUgb:remove() and visit www.google.com
  • Using the logger disable the above filter via the exceptor widget
  • Refresh the page and the filter still gets applied.

@gorhill
Copy link
Owner Author

@gorhill gorhill commented on bc19a93 Feb 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with ac25b2d.

Please sign in to comment.