You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
4 years ago
|
"use strict";
|
||
|
var ext_api = chrome || browser;
|
||
|
|
||
|
window.addEventListener("load", function () {
|
||
4 years ago
|
var opt_in_enabled = document.getElementById('opt-in-enabled');
|
||
4 years ago
|
ext_api.storage.local.get("optIn", function (result) {
|
||
4 years ago
|
opt_in_enabled.innerText = result.optIn ? 'YES' : 'NO';
|
||
4 years ago
|
});
|
||
|
|
||
4 years ago
|
document.getElementById("optin-enable").addEventListener(
|
||
4 years ago
|
"click",
|
||
|
function () {
|
||
4 years ago
|
ext_api.storage.local.set({
|
||
4 years ago
|
"optIn": true,
|
||
|
"optInShown": true
|
||
|
});
|
||
4 years ago
|
opt_in_enabled.innerText = 'YES';
|
||
4 years ago
|
});
|
||
|
|
||
4 years ago
|
document.getElementById("optin-disable").addEventListener(
|
||
4 years ago
|
"click",
|
||
|
function () {
|
||
4 years ago
|
ext_api.storage.local.set({
|
||
4 years ago
|
"optIn": false,
|
||
|
"optInShown": true
|
||
|
});
|
||
4 years ago
|
opt_in_enabled.innerText = 'NO';
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
4 years ago
|
document.getElementById("button-close").addEventListener(
|
||
|
"click",
|
||
|
function () {
|
||
4 years ago
|
ext_api.storage.local.set({
|
||
4 years ago
|
"optInShown": true,
|
||
|
"customShown": true
|
||
4 years ago
|
});
|
||
4 years ago
|
open(location).close();
|
||
4 years ago
|
});
|
||
|
|
||
4 years ago
|
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';
|
||
|
}
|
||
4 years ago
|
ext_api.storage.local.set({
|
||
4 years ago
|
"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 {}
|
||
4 years ago
|
ext_api.storage.local.set({
|
||
4 years ago
|
"customShown": true
|
||
|
});
|
||
|
});
|
||
|
});
|
||
4 years ago
|
});
|