[mv3] Fix strict-block exceptions caused duplicate rule ids

Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/304
This commit is contained in:
Raymond Hill 2025-05-05 08:04:21 -04:00
parent 3cd04c3806
commit 58f5c53fbb
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -49,10 +49,18 @@ let sessionRegexCount = 0;
const isStrictBlockRule = rule => {
if ( rule.priority !== STRICTBLOCK_PRIORITY ) { return false; }
if ( rule.action.type !== 'redirect' ) { return false; }
const substitution = rule.action.redirect.regexSubstitution;
return substitution !== undefined &&
substitution.includes('/strictblock.');
if ( rule.condition?.resourceTypes === undefined ) { return false; }
if ( rule.condition.resourceTypes.length !== 1 ) { return false; }
if ( rule.condition.resourceTypes[0] !== 'main_frame' ) { return false; }
if ( rule.action.type === 'redirect' ) {
const substitution = rule.action.redirect.regexSubstitution;
return substitution !== undefined &&
substitution.includes('/strictblock.');
}
if ( rule.action.type === 'allow' ) {
return Array.isArray(rule.condition?.requestDomains);
}
return false;
};
/******************************************************************************/
@ -365,7 +373,7 @@ async function updateStrictBlockRules(currentRules, addRules, removeRuleIds) {
const allExcluded = permanentlyExcluded.concat(temporarilyExcluded);
if ( allExcluded.length === 0 ) { return; }
addRules.push({
addRules.unshift({
action: { type: 'allow' },
condition: {
requestDomains: allExcluded,