Update custom sites (fix optional permissions)

merge-requests/10/head
magnolia1234 1 year ago
parent 9dce981078
commit cb5dc72cdc

@ -13,6 +13,7 @@ Fix New York Magazine sites (timing cookies)
Update block general paywall script (Axate.io)
Update custom sites (block_js_inline)
Update custom sites (cs_code: remove/unhide in dom)
Update custom sites (fix optional permissions)
* v2.9.8.0 (2022-12-18)
Add CaravanMagazine.in

@ -35,7 +35,7 @@
"page": "options/options.html"
},
"optional_permissions": [
"*://*/*"
"<all_urls>"
],
"content_scripts": [{
"matches": [

@ -1,5 +1,9 @@
"use strict";
var ext_api = chrome || browser;
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;
window.addEventListener("load", function () {
var opt_in_enabled = document.getElementById('opt-in-enabled');
@ -42,6 +46,8 @@ window.addEventListener("load", function () {
}
});
if (custom_switch) {
document.querySelector('#custom-enable').addEventListener('click', function (event) {
ext_api.permissions.request({
origins: ["*://*/*"]
@ -62,7 +68,7 @@ window.addEventListener("load", function () {
document.querySelector('#custom-disable').addEventListener('click', function (event) {
ext_api.permissions.remove({
origins: ["*://*/*"]
origins: ["*://*/*", "<all_urls>"]
}, function (removed) {
if (removed) {
custom_enabled.innerText = 'NO';
@ -76,6 +82,8 @@ window.addEventListener("load", function () {
});
});
}// custom_switch
var counter_enabled = document.getElementById('counter-enabled');
ext_api.storage.local.get({counter: true}, function (result) {
counter_enabled.innerText = result.counter ? 'YES' : 'NO';

Loading…
Cancel
Save