78 lines
2.3 KiB
JavaScript
Raw Normal View History

"use strict";
var ext_api = chrome || browser;
window.addEventListener("load", function () {
var opt_in_enabled = document.getElementById('opt-in-enabled');
ext_api.storage.local.get("optIn", function (result) {
opt_in_enabled.innerText = result.optIn ? 'YES' : 'NO';
});
document.getElementById("optin-enable").addEventListener("click", function () {
ext_api.storage.local.set({
"optIn": true,
"optInShown": true
});
opt_in_enabled.innerText = 'YES';
});
document.getElementById("optin-disable").addEventListener("click", function () {
ext_api.storage.local.set({
"optIn": false,
"optInShown": true
});
opt_in_enabled.innerText = 'NO';
});
document.getElementById("button-close").addEventListener("click", function () {
ext_api.storage.local.set({
2020-10-15 08:34:56 +02:00
"optInShown": true,
"customShown": true
2020-10-14 17:48:12 +02:00
});
2021-02-17 19:11:07 +01:00
open(location).close();
2020-10-14 17:48:12 +02:00
});
var custom_enabled = document.getElementById('custom-enabled');
ext_api.permissions.contains({
origins: ["<all_urls>"]
}, function (result) {
if (result) {
custom_enabled.innerText = 'YES';
} else {
custom_enabled.innerText = 'NO';
}
});
document.querySelector('#custom-enable').addEventListener('click', function (event) {
ext_api.permissions.request({
origins: ["<all_urls>"]
}, function (granted) {
if (granted) {
custom_enabled.innerText = 'YES';
ext_api.storage.local.set({
"customOptIn": true
});
} else {
custom_enabled.innerText = 'NO';
}
ext_api.storage.local.set({
"customShown": true
});
});
});
document.querySelector('#custom-disable').addEventListener('click', function (event) {
ext_api.permissions.remove({
origins: ["<all_urls>"]
}, function (removed) {
if (removed) {
custom_enabled.innerText = 'NO';
ext_api.storage.local.set({
"customOptIn": false
});
}
ext_api.storage.local.set({
"customShown": true
});
});
});
});