mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
draft
This commit is contained in:
parent
3c13d279fd
commit
635a6d9268
8 changed files with 27 additions and 60 deletions
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>' ],
|
||||
|
|
|
|||
|
|
@ -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"/
|
||||
|
|
|
|||
Loading…
Reference in a new issue