aboutsummaryrefslogtreecommitdiff
path: root/lib/extension.js
blob: e74c87735d9e82e93670a6f71d00dbcc09ec0892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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);
}