mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-10 05:17:46 +01:00
Update badge (notification: update & custom permissions)
This commit is contained in:
parent
5d3b2edf96
commit
4ee999472a
5 changed files with 37 additions and 4 deletions
|
@ -723,6 +723,9 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (key === 'version_new') {
|
||||
version_new = storageChange.newValue;
|
||||
}
|
||||
// reset disableJavascriptOnListedSites eventListener
|
||||
ext_api.webRequest.onBeforeRequest.removeListener(disableJavascriptOnListedSites);
|
||||
ext_api.webRequest.handlerBehaviorChanged();
|
||||
|
@ -1193,6 +1196,8 @@ function updateBadge(activeTab) {
|
|||
badgeText = 'OFF';
|
||||
color = 'blue';
|
||||
}
|
||||
if (version_new)
|
||||
badgeText = '^' + badgeText;
|
||||
let isDefaultSite = matchUrlDomain(defaultSites_domains, currentUrl);
|
||||
let isCustomSite = matchUrlDomain(customSites_domains, currentUrl);
|
||||
if (!isDefaultSite && isCustomSite) {
|
||||
|
@ -1200,7 +1205,7 @@ function updateBadge(activeTab) {
|
|||
origins: ['*://*.' + isCustomSite + '/*']
|
||||
}, function (result) {
|
||||
if (!result)
|
||||
badgeText = '';
|
||||
badgeText = enabledSites.includes(isCustomSite) ? 'C' : '';
|
||||
if (color && badgeText)
|
||||
ext_api.browserAction.setBadgeBackgroundColor({color: color});
|
||||
ext_api.browserAction.setBadgeText({text: badgeText});
|
||||
|
@ -1213,6 +1218,30 @@ function updateBadge(activeTab) {
|
|||
}
|
||||
}
|
||||
|
||||
var version_new;
|
||||
check_update();
|
||||
function check_update() {
|
||||
var manifestData = ext_api.runtime.getManifest();
|
||||
var manifest_new = 'https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/raw/master/manifest.json';
|
||||
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;
|
||||
version_new = json['version'];
|
||||
if (version_new.substring(0, version_len) <= manifestData.version.substring(0, version_len))
|
||||
version_new = '';
|
||||
ext_api.storage.local.set({
|
||||
version_new: version_new
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function site_switch() {
|
||||
ext_api.tabs.query({
|
||||
active: true,
|
||||
|
|
|
@ -7,6 +7,7 @@ Add Levante-EMV (Spain)
|
|||
Add L'Oeil de la Photographie (fr/en)
|
||||
Add The New Atlantis
|
||||
Update custom sites (optional: only permissions for added sites)
|
||||
Update badge (notification: update & custom permissions)
|
||||
|
||||
* v2.1.8.0 (2021-04-25)
|
||||
Add Il Giorno (Italy)
|
||||
|
|
|
@ -508,5 +508,5 @@
|
|||
"*://*.wallkit.net/*",
|
||||
"*://*.wsj.net/*"
|
||||
],
|
||||
"version": "2.1.8.5"
|
||||
"version": "2.1.8.6"
|
||||
}
|
|
@ -203,7 +203,7 @@ function remove_permissions() {
|
|||
var perm_custom = document.getElementById('perm-custom');
|
||||
var custom_enabled = document.getElementById('custom-enabled');
|
||||
ext_api.permissions.remove({
|
||||
origins: ["<all_urls>"]
|
||||
origins: perm_origins
|
||||
}, function (removed) {
|
||||
if (removed) {
|
||||
perm_custom.innerText = 'NO';
|
||||
|
|
|
@ -20,6 +20,9 @@ fetch(manifest_new)
|
|||
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({
|
||||
version_new: version_new
|
||||
});
|
||||
anchorEl = document.createElement('a');
|
||||
anchorEl.innerText = 'New release v' + version_new;
|
||||
if (manifestData.applications && manifestData.applications.gecko.id.includes('magnolia')) {
|
||||
|
|
Loading…
Reference in a new issue