This commit is contained in:
Raymond Hill 2024-12-03 08:54:23 -05:00
parent 3c13d279fd
commit 635a6d9268
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
8 changed files with 27 additions and 60 deletions

View file

@ -41,15 +41,5 @@
"storage": {
"managed_schema": "managed_storage.json"
},
"version": "1.0",
"web_accessible_resources": [
{
"resources": [
"/strict-block.html"
],
"matches": [
"<all_urls>"
]
}
]
"version": "1.0"
}

View file

@ -37,7 +37,6 @@ import {
dnr,
localRead, localRemove, localWrite,
runtime,
sessionRemove,
windows,
} from './ext.js';
@ -369,10 +368,6 @@ function onMessage(request, sender, callback) {
async function start() {
await loadRulesetConfig();
if ( process.wakeupRun === false ) {
sessionRemove('excludedStrictBlockHostnames');
}
const rulesetsUpdated = process.wakeupRun === false &&
await enableRulesets(rulesetConfig.enabledRulesets);

View file

@ -72,30 +72,6 @@ function getRulesetDetails() {
/******************************************************************************/
function getDynamicRules(...args) {
if ( getDynamicRules.promise !== undefined ) {
return getDynamicRules.promise;
}
getDynamicRules.promise = dnr.getDynamicRules(...args).then(rules => {
getDynamicRules.promise = undefined;
return rules;
});
return getDynamicRules.promise;
}
function getSessionRules(...args) {
if ( getSessionRules.promise !== undefined ) {
return getSessionRules.promise;
}
getSessionRules.promise = dnr.getSessionRules(...args).then(rules => {
getSessionRules.promise = undefined;
return rules;
});
return getSessionRules.promise;
}
/******************************************************************************/
async function pruneInvalidRegexRules(realm, rulesIn) {
const rejectedRegexRules = [];
@ -329,12 +305,21 @@ async function updateStrictBlockRules(dynamicRules, sessionRules) {
toStrictBlock.delete(hn);
}
if ( toStrictBlock.size === 0 ) { return; }
const manifest = runtime.getManifest();
let strictblockPath = '';
for ( const war of manifest.web_accessible_resources ) {
if ( war.resources.length !== 1 ) { continue; }
if ( war.resources[0].startsWith('/strict-block.') === false ) { continue; }
strictblockPath = runtime.getURL(war.resources[0]);
break;
}
if ( strictblockPath === '' ) { return; }
const dynamicRule = {
id: dynamicRuleId++,
action: {
type: 'redirect',
redirect: {
regexSubstitution: `${runtime.getURL('/strict-block.html')}#\\0`,
regexSubstitution: `${strictblockPath}#\\0`,
},
},
condition: {
@ -368,19 +353,18 @@ async function updateStrictBlockRules(dynamicRules, sessionRules) {
/******************************************************************************/
async function updateDynamicRules() {
dynamicRuleId = 1;
sessionRuleId = 1;
dynamicRuleId = sessionRuleId = 1;
const dynamicRules = [];
const sessionRules = [];
const [
dynamicRuleIds,
sessionRuleIds,
] = await Promise.all([
getDynamicRules().then(rules =>
dnr.getDynamicRules().then(rules =>
rules.map(rule => rule.id)
.filter(id => id < TRUSTED_DIRECTIVE_BASE_RULE_ID)
),
getSessionRules().then(rules => rules.map(rule => rule.id)),
dnr.getSessionRules().then(rules => rules.map(rule => rule.id)),
updateRegexRules(dynamicRules),
updateRemoveparamRules(dynamicRules),
updateRedirectRules(dynamicRules),
@ -429,7 +413,7 @@ async function updateDynamicRules() {
/******************************************************************************/
async function filteringModesToDNR(modes) {
const trustedRules = await getDynamicRules({
const trustedRules = await dnr.getDynamicRules({
ruleIds: [ TRUSTED_DIRECTIVE_BASE_RULE_ID+0 ],
});
const trustedRule = trustedRules.length !== 0 && trustedRules[0] || undefined;

View file

@ -160,9 +160,7 @@ if ( window.history.length > 1 ) {
qs$('#bye').style.display = 'none';
} else {
dom.on('#bye', 'click', ( ) => {
sendMessage({
what: 'closeThisTab',
});
window.close();
});
qs$('#back').style.display = 'none';
}

View file

@ -50,15 +50,5 @@
"storage"
],
"short_name": "uBO Lite",
"version": "1.0",
"web_accessible_resources": [
{
"resources": [
"/strict-block.html"
],
"matches": [
"<all_urls>"
]
}
]
"version": "1.0"
}

View file

@ -1361,6 +1361,15 @@ async function main() {
// Patch declarative_net_request key
manifest.declarative_net_request = { rule_resources: ruleResources };
// Patch web_accessible_resources key
manifest.web_accessible_resources = manifest.web_accessible_resources || [];
// Strict-block-related resource
const strictblockDocument = `strict-block.${secret}.html`;
copyFile('./strict-block.html', `${outputDir}/${strictblockDocument}`);
manifest.web_accessible_resources.push({
resources: [ `/${strictblockDocument}` ],
matches: [ '<all_urls>' ],
});
// Secondary resources
const web_accessible_resources = {
resources: Array.from(requiredRedirectResources).map(path => `/${path}`),
matches: [ '<all_urls>' ],

View file

@ -107,6 +107,7 @@ if [ "$QUICK" != "yes" ]; then
cp platform/mv3/package.json "$TMPDIR"/
cp platform/mv3/*.js "$TMPDIR"/
cp platform/mv3/*.mjs "$TMPDIR"/
cp platform/mv3/*.html "$TMPDIR"/
cp platform/mv3/extension/js/utils.js "$TMPDIR"/js/
cp -R "$UBO_DIR"/src/js/resources "$TMPDIR"/js/
cp "$UBO_DIR"/assets/assets.dev.json "$TMPDIR"/