mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
[mv3] Use parameter name as url filter where possible
Related issue: https://github.com/uBlockOrigin/uBOL-home/discussions/575
This commit is contained in:
parent
41dd3bf5f2
commit
85f587162f
1 changed files with 14 additions and 15 deletions
|
|
@ -4732,19 +4732,20 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
|
|||
}
|
||||
case 'removeparam': {
|
||||
rule.action.type = 'redirect';
|
||||
if ( rule.__modifierValue === '|' ) {
|
||||
rule.__modifierValue = '';
|
||||
let paramName = rule.__modifierValue;
|
||||
if ( paramName === '|' ) {
|
||||
paramName = '';
|
||||
}
|
||||
if ( rule.__modifierValue !== '' ) {
|
||||
if ( paramName !== '' ) {
|
||||
rule.action.redirect = {
|
||||
transform: {
|
||||
queryTransform: {
|
||||
removeParams: [ rule.__modifierValue ]
|
||||
removeParams: [ paramName ]
|
||||
}
|
||||
}
|
||||
};
|
||||
if ( /^~?\/.+\/$/.test(rule.__modifierValue) ) {
|
||||
dnrAddRuleError(rule, `Unsupported regex-based removeParam: ${rule.__modifierValue}`);
|
||||
if ( /^~?\/.+\/$/.test(paramName) ) {
|
||||
dnrAddRuleError(rule, `Unsupported regex-based removeParam: ${paramName}`);
|
||||
}
|
||||
} else {
|
||||
rule.action.redirect = {
|
||||
|
|
@ -4766,15 +4767,13 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
|
|||
];
|
||||
}
|
||||
}
|
||||
// https://github.com/uBlockOrigin/uBOL-home/issues/140
|
||||
// Mitigate until DNR API flaw is addressed by browser vendors
|
||||
let priority = rule.priority || 1;
|
||||
if ( rule.condition.urlFilter !== undefined ) { priority += 1; }
|
||||
if ( rule.condition.regexFilter !== undefined ) { priority += 1; }
|
||||
if ( rule.condition.initiatorDomains !== undefined ) { priority += 1; }
|
||||
if ( rule.condition.requestDomains !== undefined ) { priority += 1; }
|
||||
if ( priority !== 1 ) {
|
||||
rule.priority = priority;
|
||||
// https://github.com/uBlockOrigin/uBOL-home/discussions/575
|
||||
if ( rule.condition.urlFilter === undefined ) {
|
||||
if ( rule.condition.regexFilter === undefined ) {
|
||||
if ( paramName !== '' ) {
|
||||
rule.condition.urlFilter = `^${paramName}=`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( rule.__modifierAction === ALLOW_REALM ) {
|
||||
dnrAddRuleError(rule, `Unsupported removeparam exception: ${rule.__modifierValue}`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue