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 Seattle Times (update)
Fix The Telegraph (modal) Fix The Telegraph (modal)
Fix The West Australian (regional) Fix The West Australian (regional)
Update popup (no more version-check)
* v2.5.3.1 (2022-01-23) * v2.5.3.1 (2022-01-23)
Hotfix block inline script Hotfix block inline script

View File

@ -613,5 +613,5 @@
"*://*.wsj.net/*", "*://*.wsj.net/*",
"*://*.zephr.com/*" "*://*.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="clear_cookies" title="clear cookies (and local storage) for current site">clear cookies</button> |
<button id="button-close" title="close popup">close</button></div> <button id="button-close" title="close popup">close</button></div>
<div><span id="version_new"></span></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> <script src="popup.js"></script>
</body> </body>
</html> </html>

View File

@ -7,25 +7,17 @@ var versionString_new = document.getElementById('version_new');
versionString_new.setAttribute('style', 'font-weight: bold;'); versionString_new.setAttribute('style', 'font-weight: bold;');
var anchorEl; var anchorEl;
function check_version_update() { function show_update(ext_version_new, check = true) {
const proxyurl = "https://bpc-cors-anywhere.herokuapp.com/"; if (ext_version_new) {
//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) { ext_api.management.getSelf(function (result) {
var installType = result.installType; var installType = result.installType;
var version_len = (installType === 'development') ? 7 : 5; var version_len = (installType === 'development') ? 7 : 5;
var version_new = json['version']; if (ext_version_new.substring(0, version_len) > manifestData.version.substring(0, version_len)) {
if (version_new.substring(0, version_len) > manifestData.version.substring(0, version_len)) {
ext_api.storage.local.set({ ext_api.storage.local.set({
ext_version_new: version_new ext_version_new: ext_version_new
}); });
anchorEl = document.createElement('a'); anchorEl = document.createElement('a');
anchorEl.innerText = 'New release v' + version_new; anchorEl.innerText = 'New release v' + ext_version_new;
if (manifestData.applications && manifestData.applications.gecko.id.includes('magnolia')) { if (manifestData.applications && manifestData.applications.gecko.id.includes('magnolia')) {
if (installType === 'development') if (installType === 'development')
anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean'; anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean';
@ -35,11 +27,6 @@ function check_version_update() {
anchorEl.href = 'https://addons.mozilla.org/en-US/firefox/addon/bypass-paywalls-clean'; anchorEl.href = 'https://addons.mozilla.org/en-US/firefox/addon/bypass-paywalls-clean';
anchorEl.target = '_blank'; anchorEl.target = '_blank';
versionString_new.appendChild(anchorEl); 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')) { if (!manifestData.name.includes('Clean')) {
let par = document.createElement('p'); let par = document.createElement('p');
par.innerHTML = "<strong>You've installed a fake version of BPC (check GitLab)</strong>"; par.innerHTML = "<strong>You've installed a fake version of BPC (check GitLab)</strong>";
@ -47,20 +34,41 @@ function check_version_update() {
} }
} }
}); });
}) } else if (check) {
} else {
anchorEl = document.createElement('a'); anchorEl = document.createElement('a');
anchorEl.text = 'Check Twitter for latest update'; anchorEl.text = 'Check Twitter for latest update';
anchorEl.href = 'https://twitter.com/Magnolia1234B'; anchorEl.href = 'https://twitter.com/Magnolia1234B';
anchorEl.target = '_blank'; anchorEl.target = '_blank';
versionString_new.appendChild(anchorEl); versionString_new.appendChild(anchorEl);
} }
}
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) { }).catch(function (err) {
false; false;
}); });
} else
show_update(ext_version_new, false);
} }
ext_api.storage.local.get({optInUpdate: true}, function (result) { ext_api.storage.local.get({optInUpdate: true, ext_version_new: false}, function (result) {
if (result.optInUpdate) if (result.optInUpdate) {
check_version_update(); let popup = document.querySelector('script[id="popup"]');
check_version_update(result.ext_version_new, popup);
}
}); });