aboutsummaryrefslogtreecommitdiff
path: root/modules/firefox.home/chrome/customNewTab.uc.js
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-08-21 21:32:25 +0530
committerAkshay Nair <phenax5@gmail.com>2024-08-21 21:32:25 +0530
commit397f3cdf4862c2912212a00cd799a920b654aa8a (patch)
tree1608ff3dc7c97d06d01b6ab1a80fa082cf2669ea /modules/firefox.home/chrome/customNewTab.uc.js
parent1491b71d692a19d11fa2f6bbe25b021303a93bea (diff)
downloadnixos-config-397f3cdf4862c2912212a00cd799a920b654aa8a.tar.gz
nixos-config-397f3cdf4862c2912212a00cd799a920b654aa8a.zip
Move firefox config to autoconfig.js file
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;
+})();