aboutsummaryrefslogtreecommitdiff
path: root/modules/firefox.home/chrome
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
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')
-rw-r--r--modules/firefox.home/chrome/customNewTab.uc.js38
-rw-r--r--modules/firefox.home/chrome/globalKeybindings.uc.js1
-rw-r--r--modules/firefox.home/chrome/setupNewTab.uc.js20
3 files changed, 38 insertions, 21 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;
+})();
diff --git a/modules/firefox.home/chrome/globalKeybindings.uc.js b/modules/firefox.home/chrome/globalKeybindings.uc.js
index 7341fc0..51326fd 100644
--- a/modules/firefox.home/chrome/globalKeybindings.uc.js
+++ b/modules/firefox.home/chrome/globalKeybindings.uc.js
@@ -6,7 +6,6 @@
// @shutdown UC.globalKeybindings.destroy();
// ==/UserScript==
-
(() => {
// Configure global keybindings
const KEYBINDINGS = () => ({
diff --git a/modules/firefox.home/chrome/setupNewTab.uc.js b/modules/firefox.home/chrome/setupNewTab.uc.js
deleted file mode 100644
index 1eb971c..0000000
--- a/modules/firefox.home/chrome/setupNewTab.uc.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// ==UserScript==
-// @name Custom New Tab
-// @version 1.0
-// @description Load a custom link or local file, instead of the default new tab page (about:newtab).
-// ==/UserScript==
-
-// For Firefox 72 onward, see the autoconfig alternative to this:
-// https://support.mozilla.org/questions/1251199#answer-1199709
-
-globalThis.newtabLinkStarted = true;
-
-if (!AboutNewTab) {
- globalThis.AboutNewTab = ChromeUtils.import('resource:///modules/AboutNewTab.jsm').AboutNewTab;
-}
-
-const newTabUrl = xPref.get('browser.newtab.url') || 'about:blank';
-
-AboutNewTab.newTabURL = newTabUrl;
-
-console.log('Updated new tab url to', newTabUrl);