Update popup (no more version-check)

merge-requests/3/head
magnolia1234 3 years ago
parent 210f14eae5
commit 8eb9806863

@ -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

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

@ -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>

@ -7,60 +7,68 @@ 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'; ext_api.management.getSelf(function (result) {
const manifest_new = 'https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/raw/master/manifest.json'; var installType = result.installType;
//fetch(proxyurl + manifest_new, { headers: { "Content-Type": "application/json", "X-Requested-With": "XMLHttpRequest" } }) var version_len = (installType === 'development') ? 7 : 5;
fetch(manifest_new) if (ext_version_new.substring(0, version_len) > manifestData.version.substring(0, version_len)) {
.then(response => { ext_api.storage.local.set({
if (response.ok) { ext_version_new: ext_version_new
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);
}
}
}); });
}) anchorEl = document.createElement('a');
} else { anchorEl.innerText = 'New release v' + ext_version_new;
anchorEl = document.createElement('a'); if (manifestData.applications && manifestData.applications.gecko.id.includes('magnolia')) {
anchorEl.text = 'Check Twitter for latest update'; if (installType === 'development')
anchorEl.href = 'https://twitter.com/Magnolia1234B'; anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean';
anchorEl.target = '_blank'; else
versionString_new.appendChild(anchorEl); anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/releases';
} } else
}).catch(function (err) { anchorEl.href = 'https://addons.mozilla.org/en-US/firefox/addon/bypass-paywalls-clean';
false; 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);
}
}
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}, 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);
}
}); });

Loading…
Cancel
Save