Update popup (no more version-check)

This commit is contained in:
magnolia1234 2022-01-30 18:23:28 +01:00
parent 210f14eae5
commit 8eb9806863
4 changed files with 64 additions and 55 deletions

View file

@ -11,6 +11,7 @@ Fix The Chronicle (amp-redirect)
Fix The Seattle Times (update)
Fix The Telegraph (modal)
Fix The West Australian (regional)
Update popup (no more version-check)
* v2.5.3.1 (2022-01-23)
Hotfix block inline script

View file

@ -613,5 +613,5 @@
"*://*.wsj.net/*",
"*://*.zephr.com/*"
],
"version": "2.5.3.6"
"version": "2.5.3.7"
}

View file

@ -25,7 +25,7 @@
<button id="clear_cookies" title="clear cookies (and local storage) for current site">clear cookies</button> |
<button id="button-close" title="close popup">close</button></div>
<div><span id="version_new"></span></div>
<script src="version.js"></script>
<script id="popup" src="version.js"></script>
<script src="popup.js"></script>
</body>
</html>

View file

@ -7,60 +7,68 @@ var versionString_new = document.getElementById('version_new');
versionString_new.setAttribute('style', 'font-weight: bold;');
var anchorEl;
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({
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);
}
}
function show_update(ext_version_new, check = true) {
if (ext_version_new) {
ext_api.management.getSelf(function (result) {
var installType = result.installType;
var version_len = (installType === 'development') ? 7 : 5;
if (ext_version_new.substring(0, version_len) > manifestData.version.substring(0, version_len)) {
ext_api.storage.local.set({
ext_version_new: ext_version_new
});
})
} 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);
}
}).catch(function (err) {
false;
});
anchorEl = document.createElement('a');
anchorEl.innerText = 'New release v' + ext_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('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 if (check) {
anchorEl = document.createElement('a');
anchorEl.text = 'Check Twitter for latest update';
anchorEl.href = 'https://twitter.com/Magnolia1234B';
anchorEl.target = '_blank';
versionString_new.appendChild(anchorEl);
}
}
ext_api.storage.local.get({optInUpdate: true}, function (result) {
if (result.optInUpdate)
check_version_update();
function check_version_update(ext_version_new, popup) {
if (!popup) {
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 => {
var version_new = json['version'];
show_update(version_new);
})
} else {
show_update(ext_version_new);
}
}).catch(function (err) {
false;
});
} else
show_update(ext_version_new, false);
}
ext_api.storage.local.get({optInUpdate: true, ext_version_new: false}, function (result) {
if (result.optInUpdate) {
let popup = document.querySelector('script[id="popup"]');
check_version_update(result.ext_version_new, popup);
}
});