2022-02-20 07:25:25 +00:00
|
|
|
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
|
|
|
var url_loc = (typeof browser === 'object') ? 'firefox' : 'chrome';
|
2020-03-25 18:31:28 +00:00
|
|
|
|
|
|
|
var manifestData = ext_api.runtime.getManifest();
|
2019-01-06 01:04:40 +00:00
|
|
|
var versionString = 'v' + manifestData.version;
|
2020-02-21 17:49:49 +00:00
|
|
|
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-02-21 17:49:49 +00:00
|
|
|
|
2022-01-30 17:23:28 +00:00
|
|
|
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
|
2021-11-10 16:46:22 +00:00
|
|
|
});
|
2022-01-30 17:23:28 +00:00
|
|
|
anchorEl = document.createElement('a');
|
|
|
|
if (manifestData.applications && manifestData.applications.gecko.id.includes('magnolia')) {
|
|
|
|
if (installType === 'development')
|
2022-02-20 07:25:25 +00:00
|
|
|
anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-' + url_loc + '-clean';
|
2022-11-10 07:44:10 +00:00
|
|
|
else {
|
2022-02-20 07:25:25 +00:00
|
|
|
anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-' + url_loc + '-clean/-/releases';
|
2022-11-10 07:44:10 +00:00
|
|
|
ext_version_new = ext_version_new.replace(/\d$/, '0');
|
|
|
|
}
|
2022-01-30 17:23:28 +00:00
|
|
|
} else
|
|
|
|
anchorEl.href = 'https://addons.mozilla.org/en-US/firefox/addon/bypass-paywalls-clean';
|
2022-11-10 07:44:10 +00:00
|
|
|
if (installType !== 'development')
|
|
|
|
ext_version_new = ext_version_new.replace(/\d$/, '0');
|
|
|
|
anchorEl.innerText = 'New release v' + ext_version_new;
|
2022-01-30 17:23:28 +00:00
|
|
|
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) {
|
2022-02-20 07:25:25 +00:00
|
|
|
let manifest_new = 'https://gitlab.com/magnolia1234/bypass-paywalls-' + url_loc + '-clean/raw/master/manifest.json';
|
2022-02-22 16:35:16 +00:00
|
|
|
fetch(manifest_new)
|
2022-01-30 17:23:28 +00:00
|
|
|
.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);
|
2021-11-10 16:46:22 +00:00
|
|
|
}
|
|
|
|
|
2022-01-30 17:23:28 +00:00
|
|
|
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);
|
|
|
|
}
|
2021-05-02 05:51:25 +00:00
|
|
|
});
|