2020-09-08 14:38:18 +00:00
|
|
|
"use strict";
|
2022-12-27 11:57:29 +00:00
|
|
|
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
|
|
|
var manifestData = ext_api.runtime.getManifest();
|
|
|
|
var navigator_ua = navigator.userAgent;
|
|
|
|
var navigator_ua_mobile = navigator_ua.toLowerCase().includes('mobile');
|
|
|
|
var custom_switch = manifestData.optional_permissions && !navigator_ua_mobile;
|
2020-09-08 14:38:18 +00:00
|
|
|
|
|
|
|
window.addEventListener("load", function () {
|
2020-09-22 19:06:28 +00:00
|
|
|
var opt_in_enabled = document.getElementById('opt-in-enabled');
|
2020-10-31 19:06:38 +00:00
|
|
|
ext_api.storage.local.get("optIn", function (result) {
|
2020-09-22 19:06:28 +00:00
|
|
|
opt_in_enabled.innerText = result.optIn ? 'YES' : 'NO';
|
2020-09-08 14:38:18 +00:00
|
|
|
});
|
|
|
|
|
2021-04-03 17:03:46 +00:00
|
|
|
document.getElementById("optin-enable").addEventListener("click", function () {
|
2020-10-31 19:06:38 +00:00
|
|
|
ext_api.storage.local.set({
|
2020-09-08 14:38:18 +00:00
|
|
|
"optIn": true,
|
|
|
|
"optInShown": true
|
|
|
|
});
|
2020-09-22 19:06:28 +00:00
|
|
|
opt_in_enabled.innerText = 'YES';
|
2020-09-08 14:38:18 +00:00
|
|
|
});
|
|
|
|
|
2021-04-03 17:03:46 +00:00
|
|
|
document.getElementById("optin-disable").addEventListener("click", function () {
|
2020-10-31 19:06:38 +00:00
|
|
|
ext_api.storage.local.set({
|
2020-09-08 14:38:18 +00:00
|
|
|
"optIn": false,
|
|
|
|
"optInShown": true
|
|
|
|
});
|
2020-09-22 19:06:28 +00:00
|
|
|
opt_in_enabled.innerText = 'NO';
|
2020-09-08 14:38:18 +00:00
|
|
|
});
|
2020-10-13 15:11:35 +00:00
|
|
|
|
2021-04-03 17:03:46 +00:00
|
|
|
document.getElementById("button-close").addEventListener("click", function () {
|
2020-10-31 19:06:38 +00:00
|
|
|
ext_api.storage.local.set({
|
2020-10-15 06:35:41 +00:00
|
|
|
"optInShown": true,
|
|
|
|
"customShown": true
|
2020-10-14 15:58:07 +00:00
|
|
|
});
|
2022-01-13 16:22:38 +00:00
|
|
|
window.close();
|
2020-10-14 15:58:07 +00:00
|
|
|
});
|
|
|
|
|
2020-10-13 15:11:35 +00:00
|
|
|
var custom_enabled = document.getElementById('custom-enabled');
|
|
|
|
ext_api.permissions.contains({
|
2021-12-03 16:21:08 +00:00
|
|
|
origins: ["*://*/*"]
|
2020-10-13 15:11:35 +00:00
|
|
|
}, function (result) {
|
|
|
|
if (result) {
|
|
|
|
custom_enabled.innerText = 'YES';
|
|
|
|
} else {
|
|
|
|
custom_enabled.innerText = 'NO';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-12-27 11:57:29 +00:00
|
|
|
if (custom_switch) {
|
|
|
|
|
2020-10-13 15:11:35 +00:00
|
|
|
document.querySelector('#custom-enable').addEventListener('click', function (event) {
|
|
|
|
ext_api.permissions.request({
|
2022-12-07 12:14:32 +00:00
|
|
|
origins: ["*://*/*"]
|
2020-10-13 15:11:35 +00:00
|
|
|
}, function (granted) {
|
|
|
|
if (granted) {
|
|
|
|
custom_enabled.innerText = 'YES';
|
2021-04-03 17:03:46 +00:00
|
|
|
ext_api.storage.local.set({
|
|
|
|
"customOptIn": true
|
|
|
|
});
|
2020-10-13 15:11:35 +00:00
|
|
|
} else {
|
|
|
|
custom_enabled.innerText = 'NO';
|
|
|
|
}
|
2020-10-31 19:06:38 +00:00
|
|
|
ext_api.storage.local.set({
|
2020-10-13 15:11:35 +00:00
|
|
|
"customShown": true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
document.querySelector('#custom-disable').addEventListener('click', function (event) {
|
|
|
|
ext_api.permissions.remove({
|
2022-12-27 11:57:29 +00:00
|
|
|
origins: ["*://*/*", "<all_urls>"]
|
2020-10-13 15:11:35 +00:00
|
|
|
}, function (removed) {
|
|
|
|
if (removed) {
|
|
|
|
custom_enabled.innerText = 'NO';
|
2021-04-03 17:03:46 +00:00
|
|
|
ext_api.storage.local.set({
|
|
|
|
"customOptIn": false
|
|
|
|
});
|
|
|
|
}
|
2020-10-31 19:06:38 +00:00
|
|
|
ext_api.storage.local.set({
|
2020-10-13 15:11:35 +00:00
|
|
|
"customShown": true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2021-10-01 12:37:21 +00:00
|
|
|
|
2022-12-27 11:57:29 +00:00
|
|
|
}// custom_switch
|
|
|
|
|
2021-10-01 12:37:21 +00:00
|
|
|
var counter_enabled = document.getElementById('counter-enabled');
|
|
|
|
ext_api.storage.local.get({counter: true}, function (result) {
|
|
|
|
counter_enabled.innerText = result.counter ? 'YES' : 'NO';
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById("counter-enable").addEventListener("click", function () {
|
|
|
|
ext_api.storage.local.set({
|
2021-11-10 16:46:22 +00:00
|
|
|
"counter": true
|
2021-10-01 12:37:21 +00:00
|
|
|
});
|
|
|
|
counter_enabled.innerText = 'YES';
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById("counter-disable").addEventListener("click", function () {
|
|
|
|
ext_api.storage.local.set({
|
2021-11-10 16:46:22 +00:00
|
|
|
"counter": false
|
2021-10-01 12:37:21 +00:00
|
|
|
});
|
|
|
|
counter_enabled.innerText = 'NO';
|
|
|
|
});
|
2021-11-10 16:46:22 +00:00
|
|
|
|
|
|
|
var update_enabled = document.getElementById('update-enabled');
|
|
|
|
ext_api.storage.local.get({optInUpdate: true}, function (result) {
|
|
|
|
update_enabled.innerText = result.optInUpdate ? 'YES' : 'NO';
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById("update-enable").addEventListener("click", function () {
|
|
|
|
ext_api.storage.local.set({
|
|
|
|
"optInUpdate": true
|
|
|
|
});
|
|
|
|
update_enabled.innerText = 'YES';
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById("update-disable").addEventListener("click", function () {
|
|
|
|
ext_api.storage.local.set({
|
|
|
|
"optInUpdate": false
|
|
|
|
});
|
|
|
|
update_enabled.innerText = 'NO';
|
|
|
|
});
|
2021-10-01 12:37:21 +00:00
|
|
|
});
|