about summary refs log tree commit diff stats
path: root/src/assets/javascripts/general.js
blob: 588c67d1cdd5d6f64131079ed28238ddf53bd95a (plain) (blame)
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
27
28
29
30
"use strict"

import utils from "./utils.js"

window.browser = window.browser || window.chrome

let exceptions

function isException(url) {
	if (exceptions && url) {
		if (exceptions.url) for (const item of exceptions.url) if (item == url.href) return true
		if (exceptions.regex) for (const item of exceptions.regex) if (new RegExp(item).test(url.href)) return true
	}
	return false
}

function init() {
	return new Promise(async resolve => {
		const options = await utils.getOptions()
		if (options) exceptions = options.exceptions
		resolve()
	})
}

init()
browser.storage.onChanged.addListener(init)

export default {
	isException,
}