From 8eb9806863bb7ea84a25c744bed2e18ee2551170 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sun, 30 Jan 2022 18:23:28 +0100 Subject: [PATCH] Update popup (no more version-check) --- changelog.txt | 1 + manifest.json | 2 +- options/popup.html | 2 +- options/version.js | 114 ++++++++++++++++++++++++--------------------- 4 files changed, 64 insertions(+), 55 deletions(-) diff --git a/changelog.txt b/changelog.txt index 10132113..4a68bd2e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -11,6 +11,7 @@ Fix The Chronicle (amp-redirect) Fix The Seattle Times (update) Fix The Telegraph (modal) Fix The West Australian (regional) +Update popup (no more version-check) * v2.5.3.1 (2022-01-23) Hotfix block inline script diff --git a/manifest.json b/manifest.json index 0babf80d..006ac991 100644 --- a/manifest.json +++ b/manifest.json @@ -613,5 +613,5 @@ "*://*.wsj.net/*", "*://*.zephr.com/*" ], - "version": "2.5.3.6" + "version": "2.5.3.7" } diff --git a/options/popup.html b/options/popup.html index aa4a1d24..cc542e78 100644 --- a/options/popup.html +++ b/options/popup.html @@ -25,7 +25,7 @@ |
- + diff --git a/options/version.js b/options/version.js index 3b38f42e..42bd6a7e 100644 --- a/options/version.js +++ b/options/version.js @@ -7,60 +7,68 @@ var versionString_new = document.getElementById('version_new'); versionString_new.setAttribute('style', 'font-weight: bold;'); var anchorEl; -function check_version_update() { - 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 => { - 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 = "You've installed a fake version of BPC (check GitLab)"; - versionString_new.appendChild(par); - } - } +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 }); - }) - } 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); - } - }).catch(function (err) { - false; - }); + anchorEl = document.createElement('a'); + anchorEl.innerText = 'New release v' + ext_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('Clean')) { + let par = document.createElement('p'); + par.innerHTML = "You've installed a fake version of BPC (check GitLab)"; + 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) { - if (result.optInUpdate) - check_version_update(); +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); + } });