2020-09-08 16:38:18 +02:00
|
|
|
"use strict";
|
|
|
|
var ext_api = chrome || browser;
|
|
|
|
|
|
|
|
window.addEventListener("load", function () {
|
2020-09-22 21:06:28 +02:00
|
|
|
var opt_in_enabled = document.getElementById('opt-in-enabled');
|
2020-10-31 20:06:38 +01:00
|
|
|
ext_api.storage.local.get("optIn", function (result) {
|
2020-09-22 21:06:28 +02:00
|
|
|
opt_in_enabled.innerText = result.optIn ? 'YES' : 'NO';
|
2020-09-08 16:38:18 +02:00
|
|
|
});
|
|
|
|
|
2020-10-15 08:35:41 +02:00
|
|
|
document.getElementById("optin-enable").addEventListener(
|
2020-09-08 16:38:18 +02:00
|
|
|
"click",
|
|
|
|
function () {
|
2020-10-31 20:06:38 +01:00
|
|
|
ext_api.storage.local.set({
|
2020-09-08 16:38:18 +02:00
|
|
|
"optIn": true,
|
|
|
|
"optInShown": true
|
|
|
|
});
|
2020-09-22 21:06:28 +02:00
|
|
|
opt_in_enabled.innerText = 'YES';
|
|
|
|
setTimeout(function () {
|
2020-10-13 17:11:35 +02:00
|
|
|
//window.close();
|
2020-09-22 21:06:28 +02:00
|
|
|
}, 800);
|
2020-09-08 16:38:18 +02:00
|
|
|
});
|
|
|
|
|
2020-10-15 08:35:41 +02:00
|
|
|
document.getElementById("optin-disable").addEventListener(
|
2020-09-08 16:38:18 +02:00
|
|
|
"click",
|
|
|
|
function () {
|
2020-10-31 20:06:38 +01:00
|
|
|
ext_api.storage.local.set({
|
2020-09-08 16:38:18 +02:00
|
|
|
"optIn": false,
|
|
|
|
"optInShown": true
|
|
|
|
});
|
2020-09-22 21:06:28 +02:00
|
|
|
opt_in_enabled.innerText = 'NO';
|
|
|
|
setTimeout(function () {
|
2020-10-13 17:11:35 +02:00
|
|
|
//window.close();
|
2020-09-22 21:06:28 +02:00
|
|
|
}, 800);
|
2020-09-08 16:38:18 +02:00
|
|
|
});
|
2020-10-13 17:11:35 +02:00
|
|
|
|
2020-10-14 17:58:07 +02:00
|
|
|
document.getElementById("button-close").addEventListener(
|
|
|
|
"click",
|
|
|
|
function () {
|
2020-10-31 20:06:38 +01:00
|
|
|
ext_api.storage.local.set({
|
2020-10-15 08:35:41 +02:00
|
|
|
"optInShown": true,
|
|
|
|
"customShown": true
|
2020-10-14 17:58:07 +02:00
|
|
|
});
|
|
|
|
window.close();
|
|
|
|
});
|
|
|
|
|
2020-10-13 17:11:35 +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';
|
|
|
|
} else {
|
|
|
|
custom_enabled.innerText = 'NO';
|
|
|
|
}
|
2020-10-31 20:06:38 +01:00
|
|
|
ext_api.storage.local.set({
|
2020-10-13 17:11:35 +02:00
|
|
|
"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';
|
|
|
|
} else {}
|
2020-10-31 20:06:38 +01:00
|
|
|
ext_api.storage.local.set({
|
2020-10-13 17:11:35 +02:00
|
|
|
"customShown": true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-09-08 16:38:18 +02:00
|
|
|
});
|