aboutsummaryrefslogtreecommitdiff
path: root/modules/firefox.home/chrome/customNewTab.uc.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/firefox.home/chrome/customNewTab.uc.js')
-rw-r--r--modules/firefox.home/chrome/customNewTab.uc.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/modules/firefox.home/chrome/customNewTab.uc.js b/modules/firefox.home/chrome/customNewTab.uc.js
new file mode 100644
index 0000000..3a3a47e
--- /dev/null
+++ b/modules/firefox.home/chrome/customNewTab.uc.js
@@ -0,0 +1,38 @@
+// ==UserScript==
+// @name Custom New Tab
+// @version 1.0
+// @description Load a custom link or local file, instead of the default new tab page
+// @startup UC.customNewTab.updateNewTabURL()
+// @shutdown UC.customNewTab.destroy();
+// ==/UserScript==
+
+(() => {
+ // Managed in about:config
+ const NEWTAB_URL_PREF = 'browser.newtab.url'
+
+ if (!AboutNewTab) {
+ globalThis.AboutNewTab = ChromeUtils.import('resource:///modules/AboutNewTab.jsm').AboutNewTab;
+ }
+
+ const module = {
+ updateNewTabURL: () => {
+ const newTabUrl = xPref.get(NEWTAB_URL_PREF) || 'about:blank';
+ if (AboutNewTab.newTabURL === newTabUrl) return;
+
+ AboutNewTab.newTabURL = newTabUrl;
+ console.log('Updated new tab url to', newTabUrl);
+ },
+
+ init() {
+ module.updateNewTabURL();
+ Services.obs.addObserver(module.updateNewTabURL, 'newtab-url-changed');
+ },
+ destroy() {
+ Services.obs.removeObserver(module.updateNewTabURL, 'newtab-url-changed');
+ },
+ };
+
+ module.init();
+
+ UC.customNewTab = module;
+})();