Check for update version on startup/options (now opt-out)

This commit is contained in:
magnolia1234 2021-11-10 17:46:22 +01:00
parent 659327c4d1
commit bb54216658
7 changed files with 100 additions and 57 deletions

View file

@ -11,6 +11,7 @@ const cs_limit_except = ['elespanol.com', 'faz.net', 'inkl.com', 'nation.africa'
var currentTabUrl = '';
var csDone = false;
var optin_setcookie = false;
var optin_update = true;
// defaultSites are loaded from sites.js at installation extension
@ -106,7 +107,8 @@ function setDefaultOptions() {
}
function check_sites_updated() {
var sites_updated_json = 'https://gitlab.com/magnolia1234/bypass-paywalls-' + url_loc + '-clean/-/raw/master/sites_updated.json';
//var sites_updated_json = 'https://gitlab.com/magnolia1234/bypass-paywalls-' + url_loc + '-clean/-/raw/master/sites_updated.json';
var sites_updated_json = 'https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/raw/master/sites_updated.json';
fetch(sites_updated_json)
.then(response => {
if (response.ok) {
@ -268,7 +270,8 @@ ext_api.storage.local.get({
sites_updated: {},
sites_excluded: [],
ext_version_old: '2.3.9.0',
optIn: false
optIn: false,
optInUpdate: true
}, function (items) {
var sites = items.sites;
optionSites = sites;
@ -277,6 +280,7 @@ ext_api.storage.local.get({
var sites_updated = items.sites_updated;
var ext_version_old = items.ext_version_old;
optin_setcookie = items.optIn;
optin_update = items.optInUpdate;
excludedSites = items.sites_excluded;
enabledSites = Object.values(sites).filter(function (val) {
@ -311,6 +315,8 @@ ext_api.storage.local.get({
set_rules(sites, updatedSites, customSites);
if (enabledSites.includes('#options_optin_update_rules'))
check_sites_updated();
if (optin_update)
check_update();
});
// Listen for changes to options
@ -393,6 +399,9 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
if (key === 'optIn') {
optin_setcookie = storageChange.newValue;
}
if (key === 'optInUpdate') {
optin_update = storageChange.newValue;
}
// reset disableJavascriptOnListedSites eventListener
ext_api.webRequest.onBeforeRequest.removeListener(disableJavascriptOnListedSites);
ext_api.webRequest.handlerBehaviorChanged();
@ -985,9 +994,9 @@ function updateBadge(activeTab) {
}
var ext_version_new;
check_update();
function check_update() {
var manifest_new = 'https://gitlab.com/magnolia1234/bypass-paywalls-' + url_loc + '-clean/-/raw/master/manifest.json';
//var manifest_new = 'https://gitlab.com/magnolia1234/bypass-paywalls-' + url_loc + '-clean/-/raw/master/manifest.json';
var manifest_new = 'https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/raw/master/manifest.json';
fetch(manifest_new)
.then(response => {
if (response.ok) {

View file

@ -3,6 +3,7 @@ Changelog Bypass Paywalls Clean - Firefox
Post-release
Fix Nikkei Asian Review (cookies)
Check for update version on startup/options (now opt-out)
* v2.4.3.0 (2021-11-07)
Add Harvard Business Review China
@ -13,7 +14,7 @@ Fix Lee Enterprises Group
Fix LesEchos.fr (json)
Fix WaPo (images)
Fix WSJ (timing)
Check for update rules at startup (opt-in)
Check for update rules on startup (opt-in)
Refactor (custom) site rules
* v2.4.2.0 (2021-10-31)

View file

@ -1332,9 +1332,9 @@ else if (matchDomain(nl_mediahuis_region_domains)) {
else if (matchDomain('nrc.nl')) {
window.setTimeout(function () {
let mijnnrc_overlay = document.querySelector('#mijnnrc__modal__overlay');
let nrc_overlay = document.querySelectorAll('[id$="modal__overlay"]');
let subscribe_bar = document.querySelector('.header__subscribe-bar');
removeDOMElement(mijnnrc_overlay, subscribe_bar);
removeDOMElement(...nrc_overlay, subscribe_bar);
let paywall = document.querySelector('.has-paywall');
if (paywall)
paywall.classList.remove('has-paywall');

View file

@ -558,5 +558,5 @@
"*://*.wallkit.net/*",
"*://*.wsj.net/*"
],
"version": "2.4.3.1"
"version": "2.4.3.2"
}

View file

@ -40,6 +40,15 @@
<button id="counter-enable">Enable</button>
<button id="counter-disable">Disable</button>
</div>
</div>
<div id="update-prompt">
<p><strong>check update opt-in</strong></p>
<p>Check for update of version (on startup and when opening options):</br>
<p>daily users counter enabled: <span id="update-enabled"></span></p>
<div id="update-container">
<button id="update-enable">Enable</button>
<button id="update-disable">Disable</button>
</div>
</div>
<p>
<div style='float:left;padding-bottom:50px'>

View file

@ -83,17 +83,34 @@ window.addEventListener("load", function () {
document.getElementById("counter-enable").addEventListener("click", function () {
ext_api.storage.local.set({
"counter": true,
"optInShown": true
"counter": true
});
counter_enabled.innerText = 'YES';
});
document.getElementById("counter-disable").addEventListener("click", function () {
ext_api.storage.local.set({
"counter": false,
"optInShown": true
"counter": false
});
counter_enabled.innerText = 'NO';
});
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';
});
});

View file

@ -7,53 +7,60 @@ var versionString_new = document.getElementById('version_new');
versionString_new.setAttribute('style', 'font-weight: bold;');
var anchorEl;
const proxyurl = "https://bpc-cors-anywhere.herokuapp.com/";
const manifest_new = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/raw/master/manifest.json';
//const manifest_new = 'https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/raw/master/manifest.json';
//fetch(proxyurl + manifest_new, { headers: { "Content-Type": "application/json", "X-Requested-With": "XMLHttpRequest" } })
fetch(manifest_new)
.then(response => {
function check_version_update() {
const proxyurl = "https://bpc-cors-anywhere.herokuapp.com/";
//const manifest_new = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/raw/master/manifest.json';
const manifest_new = 'https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/raw/master/manifest.json';
//fetch(proxyurl + manifest_new, { headers: { "Content-Type": "application/json", "X-Requested-With": "XMLHttpRequest" } })
fetch(manifest_new)
.then(response => {
if (response.ok) {
response.json().then(json => {
ext_api.management.getSelf(function (result) {
var installType = result.installType;
var version_len = (installType === 'development') ? 7 : 5;
var version_new = json['version'];
if (version_new.substring(0, version_len) > manifestData.version.substring(0, version_len)) {
ext_api.storage.local.set({
version_new: version_new
});
anchorEl = document.createElement('a');
anchorEl.innerText = 'New release v' + version_new;
if (manifestData.applications && manifestData.applications.gecko.id.includes('magnolia')) {
if (installType === 'development')
anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean';
else
anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/releases';
} else
anchorEl.href = 'https://addons.mozilla.org/en-US/firefox/addon/bypass-paywalls-clean';
anchorEl.target = '_blank';
versionString_new.appendChild(anchorEl);
if (manifestData.name.includes('(lp')) {
let par = document.createElement('p');
par.innerHTML = "Limited permissions version is no longer updated (check GitLab)";
versionString_new.appendChild(par);
}
if (!manifestData.name.includes('Clean')) {
let par = document.createElement('p');
par.innerHTML = "<strong>You've installed a fake version of BPC (check GitLab)</strong>";
versionString_new.appendChild(par);
}
}
response.json().then(json => {
ext_api.management.getSelf(function (result) {
var installType = result.installType;
var version_len = (installType === 'development') ? 7 : 5;
var version_new = json['version'];
if (version_new.substring(0, version_len) > manifestData.version.substring(0, version_len)) {
ext_api.storage.local.set({
ext_version_new: version_new
});
})
anchorEl = document.createElement('a');
anchorEl.innerText = 'New release v' + version_new;
if (manifestData.applications && manifestData.applications.gecko.id.includes('magnolia')) {
if (installType === 'development')
anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean';
else
anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/releases';
} else
anchorEl.href = 'https://addons.mozilla.org/en-US/firefox/addon/bypass-paywalls-clean';
anchorEl.target = '_blank';
versionString_new.appendChild(anchorEl);
if (manifestData.name.includes('(lp')) {
let par = document.createElement('p');
par.innerHTML = "Limited permissions version is no longer updated (check GitLab)";
versionString_new.appendChild(par);
}
if (!manifestData.name.includes('Clean')) {
let par = document.createElement('p');
par.innerHTML = "<strong>You've installed a fake version of BPC (check GitLab)</strong>";
versionString_new.appendChild(par);
}
}
});
})
} else {
anchorEl = document.createElement('a');
anchorEl.text = 'Check Twitter for latest update';
anchorEl.href = 'https://twitter.com/Magnolia1234B';
anchorEl.target = '_blank';
versionString_new.appendChild(anchorEl);
anchorEl = document.createElement('a');
anchorEl.text = 'Check Twitter for latest update';
anchorEl.href = 'https://twitter.com/Magnolia1234B';
anchorEl.target = '_blank';
versionString_new.appendChild(anchorEl);
}
}).catch(function (err) {
false;
}).catch(function (err) {
false;
});
}
ext_api.storage.local.get({optInUpdate: true}, function (result) {
if (result.optInUpdate)
check_version_update();
});