2022-07-26 23:28:50 +02:00
|
|
|
"use strict"
|
2023-01-21 12:29:10 +01:00
|
|
|
|
|
|
|
import utils from "./utils.js"
|
|
|
|
|
2022-07-26 23:28:50 +02:00
|
|
|
window.browser = window.browser || window.chrome
|
2022-02-12 20:28:36 +01:00
|
|
|
|
2022-09-25 16:10:38 +02:00
|
|
|
let exceptions
|
|
|
|
|
2022-02-12 18:40:36 +01:00
|
|
|
function isException(url) {
|
2022-07-26 23:28:50 +02:00
|
|
|
for (const item of exceptions.url) if (item == `${url.protocol}//${url.host}`) return true
|
|
|
|
for (const item of exceptions.regex) if (new RegExp(item).test(url.href)) return true
|
|
|
|
return false
|
2022-03-02 22:46:29 +01:00
|
|
|
}
|
|
|
|
|
2022-05-27 05:20:07 +02:00
|
|
|
function init() {
|
2023-01-21 12:29:10 +01:00
|
|
|
return new Promise(async resolve => {
|
|
|
|
const options = await utils.getOptions()
|
|
|
|
if (options) exceptions = options.exceptions
|
|
|
|
resolve()
|
2022-07-26 23:28:50 +02:00
|
|
|
})
|
2022-03-09 19:05:31 +01:00
|
|
|
}
|
|
|
|
|
2022-07-26 23:28:50 +02:00
|
|
|
init()
|
2022-05-27 05:20:07 +02:00
|
|
|
browser.storage.onChanged.addListener(init)
|
|
|
|
|
2022-02-12 18:40:36 +01:00
|
|
|
export default {
|
2022-07-26 23:28:50 +02:00
|
|
|
isException,
|
2022-04-09 11:19:13 +02:00
|
|
|
}
|