aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/extension.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/extension.js b/lib/extension.js
new file mode 100644
index 0000000..e74c877
--- /dev/null
+++ b/lib/extension.js
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+"use strict";
+
+const defaultSettings = {
+ enableRegExp: ".*",
+};
+
+window.browser = window.browser ?? window.chrome;
+
+async function setSetting(setting, val) {
+ await browser.storage.sync.set({ [setting]: val });
+}
+
+async function getSetting(setting) {
+ return (
+ (await browser.storage.sync.get(setting))[setting] ??
+ defaultSettings[setting]
+ );
+}
+
+async function subEnabled() {
+ return new RegExp(
+ "^" + (await getSetting("enableRegExp")).replace(/\s+/g, "") + "$"
+ ).test(window.location.host);
+}