bypass-paywalls-firefox-clean/options/optin/opt-in.js

75 lines
2.5 KiB
JavaScript
Raw Normal View History

"use strict";
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');
2023-02-19 11:36:09 +00:00
var custom_switch = ((manifestData.optional_permissions && manifestData.optional_permissions.length) || (manifestData.optional_host_permissions && manifestData.optional_host_permissions.length)) && !navigator_ua_mobile;
window.addEventListener("load", function () {
document.getElementById("button-close").addEventListener("click", function () {
2022-01-13 16:22:38 +00:00
window.close();
2020-10-14 15:58:07 +00:00
});
var custom_enabled = document.getElementById('custom-enabled');
ext_api.permissions.contains({
2021-12-03 16:21:08 +00:00
origins: ["*://*/*"]
}, function (result) {
if (result) {
custom_enabled.innerText = 'YES';
} else {
custom_enabled.innerText = 'NO';
}
});
if (custom_switch) {
document.querySelector('#custom-enable').addEventListener('click', function (event) {
ext_api.permissions.request({
origins: ["*://*/*"]
}, function (granted) {
if (granted) {
custom_enabled.innerText = 'YES';
ext_api.storage.local.set({
"customOptIn": true
});
} else {
custom_enabled.innerText = 'NO';
}
});
});
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
});
}
});
});
2021-10-01 12:37:21 +00:00
}// custom_switch
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
});