mirror of
https://github.com/morgan9e/helium
synced 2026-04-14 00:14:20 +09:00
patches/ublock: install ublock as component extension
- locked down and reconfigured component behavior - set up localization of manifest.json - todo: split up extensions/browser/extension_registrar.cc into separate patch and credit brave - added ui for extension settings to indicate u0 is a helium component - migration and services stuff, almost done - fix ublock re-enabling on next launch when disabled - more reliably refresh assets.json on pref change - add ublock pref to settings - refresh patches - part 5: pin by default, update incognito preference
This commit is contained in:
61
devutils/clear-ublock-assets.js
Normal file
61
devutils/clear-ublock-assets.js
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright 2025 The Helium Authors
|
||||
// You can use, redistribute, and/or modify this source code under
|
||||
// the terms of the GPL-3.0 license that can be found in the LICENSE file.
|
||||
|
||||
// Program for updating the assets.json file in uB0 to disable all
|
||||
// outgoing connections before the user is able to consent to them.
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const err = () => {
|
||||
console.error('usage: node clear-ublock-assets <path to uB0 assets.json');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const assets_path = process.argv[2] || err();
|
||||
|
||||
const stripURLs = (c) =>
|
||||
[c].flat().filter(s => !URL.canParse(s));
|
||||
|
||||
const breakKey = (obj, key_) => {
|
||||
const keys = Object.keys(obj);
|
||||
const idx = keys.indexOf(key_);
|
||||
|
||||
if (idx === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let key of keys.splice(idx)) {
|
||||
const val = obj[key];
|
||||
delete obj[key];
|
||||
|
||||
if (key === key_) {
|
||||
key = `^${key}`;
|
||||
}
|
||||
|
||||
obj[key] = val;
|
||||
}
|
||||
}
|
||||
|
||||
const clear = obj => {
|
||||
for (const filter of Object.values(obj)) {
|
||||
if (filter.off) {
|
||||
continue;
|
||||
}
|
||||
|
||||
filter.contentURL = stripURLs(filter.contentURL);
|
||||
breakKey(filter, 'cdnURLs');
|
||||
breakKey(filter, 'patchURLs');
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
assets_path,
|
||||
JSON.stringify(clear(
|
||||
JSON.parse(fs.readFileSync(
|
||||
assets_path
|
||||
))
|
||||
), null, '\t') + '\n'
|
||||
);
|
||||
Reference in New Issue
Block a user