bypass-paywalls-firefox-clean/version.js

52 lines
2.8 KiB
JavaScript
Raw Normal View History

var ext_api = chrome || browser;
var manifestData = ext_api.runtime.getManifest();
2019-01-06 01:04:40 +00:00
var versionString = 'v' + manifestData.version;
document.getElementById('version').innerText = versionString;
2020-12-01 16:53:32 +00:00
var versionString_new = document.getElementById('version_new');
versionString_new.setAttribute('style', 'font-weight: bold;');
var anchorEl;
2020-11-25 18:39:46 +00:00
const proxyurl = "https://cors-anywhere.herokuapp.com/";
2020-11-20 18:12:01 +00:00
const manifest_new = 'https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/raw/master/manifest.json';
2020-11-25 18:39:46 +00:00
fetch(proxyurl + manifest_new, { headers: { "Content-Type": "application/json", "X-Requested-With": "XMLHttpRequest" } })
.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)) {
2020-12-01 16:53:32 +00:00
anchorEl = document.createElement('a');
2020-12-10 19:23:12 +00:00
anchorEl.innerText = 'New release v' + version_new;
2020-12-13 12:56:12 +00:00
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);
2020-10-14 15:58:07 +00:00
if (manifestData.name.includes('(lp')) {
let par = document.createElement('p');
2020-12-01 16:53:32 +00:00
par.innerHTML = "Limited permissions version is no longer updated (check GitLab)";
2020-10-14 15:58:07 +00:00
versionString_new.appendChild(par);
}
if (!manifestData.name.includes('Clean')) {
let par = document.createElement('p');
2020-11-20 18:12:01 +00:00
par.innerHTML = "<strong>You've installed a fake version of BPC (check GitLab)</strong>";
versionString_new.appendChild(par);
}
}
});
})
2020-12-01 16:53:32 +00:00
} 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);
}
});