Backport Basilisk internal userscripts

This commit is contained in:
wuggy 2026-07-13 08:48:40 -07:00
commit 5c168f64fc
23 changed files with 2648 additions and 0 deletions

View file

@ -9,6 +9,8 @@ const Cu = Components.utils;
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const PREF_INTERNAL_USERSCRIPTS_ENABLED = "browser.internal-userscripts.enabled";
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
@ -185,6 +187,7 @@ BrowserGlue.prototype = {
break;
case "final-ui-startup":
this._finalUIStartup();
this._syncInternalUserScripts();
break;
case "browser-delayed-startup-finished":
this._onFirstWindowLoaded(subject);
@ -357,6 +360,11 @@ BrowserGlue.prototype = {
break;
case "autocomplete-did-enter-text":
break;
case "nsPref:changed":
if (data == PREF_INTERNAL_USERSCRIPTS_ENABLED) {
this._syncInternalUserScripts();
}
break;
case "test-initialize-sanitizer":
this._sanitizer.onStartup();
break;
@ -398,6 +406,7 @@ BrowserGlue.prototype = {
os.addObserver(this, "flash-plugin-hang", false);
os.addObserver(this, "xpi-signature-changed", false);
os.addObserver(this, "autocomplete-did-enter-text", false);
Services.prefs.addObserver(PREF_INTERNAL_USERSCRIPTS_ENABLED, this);
if (AppConstants.NIGHTLY_BUILD) {
os.addObserver(this, AddonWatcher.TOPIC_SLOW_ADDON_DETECTED, false);
@ -448,6 +457,7 @@ BrowserGlue.prototype = {
os.removeObserver(this, "flash-plugin-hang");
os.removeObserver(this, "xpi-signature-changed");
os.removeObserver(this, "autocomplete-did-enter-text");
Services.prefs.removeObserver(PREF_INTERNAL_USERSCRIPTS_ENABLED, this);
},
_onAppDefaults: function() {
@ -816,6 +826,15 @@ BrowserGlue.prototype = {
nb.PRIORITY_WARNING_MEDIUM, buttons);
},
_syncInternalUserScripts: function () {
let enabled = true;
try {
enabled = Services.prefs.getBoolPref(PREF_INTERNAL_USERSCRIPTS_ENABLED);
} catch (ex) {}
// Internal userscripts service checks this pref on startup.
Services.prefs.setBoolPref(PREF_INTERNAL_USERSCRIPTS_ENABLED, enabled);
},
// the first browser window has finished initializing
_onFirstWindowLoaded: function(aWindow) {
// Initialize PdfJs when running in-process and remote. This only