Update options: restore opt-in for custom sites

Synching with Chrome
This commit is contained in:
magnolia1234 2021-04-03 19:03:46 +02:00
parent 1ffeff3eab
commit f1a8335955
7 changed files with 39 additions and 13 deletions

View File

@ -1340,6 +1340,27 @@ ext_api.storage.local.get(["optInShown", "customShown"], function (result) {
}
});
// restore custom sites opt-in on reload (chrome-only, load upacked)
if (typeof browser !== 'object') {
ext_api.storage.local.get({
sites: {},
customOptIn: false
}, function (result) {
let options_restore_custom = Object.values(result.sites).includes('#options_restore_custom');
if (result.customOptIn && options_restore_custom) {
ext_api.permissions.contains({
origins: ["<all_urls>"]
}, function (result_perm) {
if (!result_perm) {
ext_api.tabs.create({
url: "options/optin/opt-in.html"
});
}
});
}
});
}
function filterObject(obj, callback) {
return Object.fromEntries(Object.entries(obj).
filter(([key, val]) => callback(val, key)));

View File

@ -16,8 +16,11 @@ function bpc_count_daily_users(dateStr) {
let count_json = 'https://bitbucket.org/bpc_redux/bpc-firefox-daily-users/downloads/bpc-daily-users-' + dateStr + '.json';
fetch(count_json, {mode: 'no-cors'});
let count_mobile_json = 'https://bitbucket.org/bpc_redux/bpc-firefox-mobile-daily-users/downloads/bpc-daily-users-' + dateStr + '.json';
let count_desktop_json = 'https://bitbucket.org/bpc_redux/bpc-firefox-desktop-daily-users/downloads/bpc-daily-users-' + dateStr + '.json';
if (window.navigator && window.navigator.userAgent.match(/(mobile|android)/i))
fetch(count_mobile_json, {mode: 'no-cors'});
else
fetch(count_desktop_json, {mode: 'no-cors'});
}
});
}

View File

@ -6,6 +6,7 @@ Add Billboard
Add La Tribune (France)
Add Le Telegramme (France)
Fix-update Mexico News Daily
Update options: restore opt-in for custom sites (on reload; Chrome-only)
* v2.1.4.0 (2021-03-28)
Add Aachener Zeitung (Germany)

View File

@ -701,8 +701,8 @@ else if (matchDomain("theglobeandmail.com")) {
}
else if (matchDomain("sofrep.com")) {
const banner = document.getElementById('scrollerCTA');
removeDOMElement(banner);
let banners = document.querySelectorAll('#scrollerCTA, #botCta');
removeDOMElement(...banners);
}
else if (matchDomain("newstatesman.com")) {

View File

@ -499,5 +499,5 @@
"*://*.wallkit.net/*",
"*://*.wsj.net/*"
],
"version": "2.1.4.4"
"version": "2.1.4.5"
}

View File

@ -7,9 +7,7 @@ window.addEventListener("load", function () {
opt_in_enabled.innerText = result.optIn ? 'YES' : 'NO';
});
document.getElementById("optin-enable").addEventListener(
"click",
function () {
document.getElementById("optin-enable").addEventListener("click", function () {
ext_api.storage.local.set({
"optIn": true,
"optInShown": true
@ -17,9 +15,7 @@ window.addEventListener("load", function () {
opt_in_enabled.innerText = 'YES';
});
document.getElementById("optin-disable").addEventListener(
"click",
function () {
document.getElementById("optin-disable").addEventListener("click", function () {
ext_api.storage.local.set({
"optIn": false,
"optInShown": true
@ -27,9 +23,7 @@ window.addEventListener("load", function () {
opt_in_enabled.innerText = 'NO';
});
document.getElementById("button-close").addEventListener(
"click",
function () {
document.getElementById("button-close").addEventListener("click", function () {
ext_api.storage.local.set({
"optInShown": true,
"customShown": true
@ -54,6 +48,9 @@ window.addEventListener("load", function () {
}, function (granted) {
if (granted) {
custom_enabled.innerText = 'YES';
ext_api.storage.local.set({
"customOptIn": true
});
} else {
custom_enabled.innerText = 'NO';
}
@ -69,7 +66,10 @@ window.addEventListener("load", function () {
}, function (removed) {
if (removed) {
custom_enabled.innerText = 'NO';
} else {}
ext_api.storage.local.set({
"customOptIn": false
});
}
ext_api.storage.local.set({
"customShown": true
});

View File

@ -296,6 +296,7 @@ var defaultSites =
"TribDss": "tribdss.com",
"* BPC settings": "###",
"Show options on update": "#options_on_update",
"Restore opt-in for custom sites (on reload; Chrome-only)": "#options_restore_custom",
"The Wall Street Journal - no Googlebot (http error 500)": "#options_disable_gb_wsj"
}