Skip to content

Commit 85f5871

Browse files
committed
[mv3] Use parameter name as url filter where possible
Related issue: uBlockOrigin/uBOL-home#575
1 parent 41dd3bf commit 85f5871

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/js/static-net-filtering.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4732,19 +4732,20 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
47324732
}
47334733
case 'removeparam': {
47344734
rule.action.type = 'redirect';
4735-
if ( rule.__modifierValue === '|' ) {
4736-
rule.__modifierValue = '';
4735+
let paramName = rule.__modifierValue;
4736+
if ( paramName === '|' ) {
4737+
paramName = '';
47374738
}
4738-
if ( rule.__modifierValue !== '' ) {
4739+
if ( paramName !== '' ) {
47394740
rule.action.redirect = {
47404741
transform: {
47414742
queryTransform: {
4742-
removeParams: [ rule.__modifierValue ]
4743+
removeParams: [ paramName ]
47434744
}
47444745
}
47454746
};
4746-
if ( /^~?\/.+\/$/.test(rule.__modifierValue) ) {
4747-
dnrAddRuleError(rule, `Unsupported regex-based removeParam: ${rule.__modifierValue}`);
4747+
if ( /^~?\/.+\/$/.test(paramName) ) {
4748+
dnrAddRuleError(rule, `Unsupported regex-based removeParam: ${paramName}`);
47484749
}
47494750
} else {
47504751
rule.action.redirect = {
@@ -4766,15 +4767,13 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
47664767
];
47674768
}
47684769
}
4769-
// https://github.com/uBlockOrigin/uBOL-home/issues/140
4770-
// Mitigate until DNR API flaw is addressed by browser vendors
4771-
let priority = rule.priority || 1;
4772-
if ( rule.condition.urlFilter !== undefined ) { priority += 1; }
4773-
if ( rule.condition.regexFilter !== undefined ) { priority += 1; }
4774-
if ( rule.condition.initiatorDomains !== undefined ) { priority += 1; }
4775-
if ( rule.condition.requestDomains !== undefined ) { priority += 1; }
4776-
if ( priority !== 1 ) {
4777-
rule.priority = priority;
4770+
// https://github.com/uBlockOrigin/uBOL-home/discussions/575
4771+
if ( rule.condition.urlFilter === undefined ) {
4772+
if ( rule.condition.regexFilter === undefined ) {
4773+
if ( paramName !== '' ) {
4774+
rule.condition.urlFilter = `^${paramName}=`;
4775+
}
4776+
}
47784777
}
47794778
if ( rule.__modifierAction === ALLOW_REALM ) {
47804779
dnrAddRuleError(rule, `Unsupported removeparam exception: ${rule.__modifierValue}`);

0 commit comments

Comments
 (0)