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:
jj
2025-09-19 00:52:48 +00:00
parent b0f30bffcf
commit 99f65cfbcd
13 changed files with 1672 additions and 71 deletions

View 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'
);