diff options
author | Nikita Krupin <krupin.nikita0110@gmail.com> | 2022-03-21 04:41:37 +0300 |
---|---|---|
committer | Nikita Krupin <krupin.nikita0110@gmail.com> | 2022-03-21 04:41:37 +0300 |
commit | 54b1b7bfb2e4b8d6ebf4909f5ca12e4efd00ec40 (patch) | |
tree | 52f5ca952dedfce9d6355d914c8bd472fe38cb79 | |
parent | f5650fcc4e21eedb5fa8e9c248f800d27d716ab1 (diff) |
fixed version checker
-rw-r--r-- | Extensions/combined/popup.js | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Extensions/combined/popup.js b/Extensions/combined/popup.js index 4ba9855..10055d1 100644 --- a/Extensions/combined/popup.js +++ b/Extensions/combined/popup.js @@ -123,15 +123,35 @@ function initializeVersionNumber() { ) .then((response) => response.json()) .then((json) => { - if (version !== json.version) { + if (compareVersions(json.version, version)) { document.getElementById("ext-update").innerHTML = - chrome.i18n.getMessage("textUpdate") + " v" + json.version; + chrome.i18n.getMessage("textUpdate") + " v" + json.version; document.getElementById("ext-update").style.padding = ".25rem .5rem"; } }); // .catch(console.error); } +// returns whether current < latest +function compareVersions(latestStr, currentStr) { + let latestarr = latestStr.split("."); + let currentarr = currentStr.split("."); + let outdated = false; + // goes through version numbers from left to right from greatest to least significant + for (let i = 0; i < latestarr.length; i++) { + let latest = parseInt(latestarr[i]); + let current = parseInt(currentarr[i]); + if (latest > current) { + outdated = true; + break; + } else if (latest < current) { + outdated = false; + break; + } + } + return outdated; +} + function initializeDisableVoteSubmission() { chrome.storage.sync.get(["disableVoteSubmission"], (res) => { handleDisableVoteSubmissionChangeEvent(res.disableVoteSubmission); |