mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-28 08:57:56 +01:00
fixed version checker
This commit is contained in:
1 parent
f5650fcc4e
commit
54b1b7bfb2
1 file changed
+22
-2
@@ -123,15 +123,35 @@ function initializeVersionNumber() {
|
|||||||
)
|
)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((json) => {
|
.then((json) => {
|
||||||
if (version !== json.version) {
|
if (compareVersions(json.version, version)) {
|
||||||
document.getElementById("ext-update").innerHTML =
|
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";
|
document.getElementById("ext-update").style.padding = ".25rem .5rem";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// .catch(console.error);
|
// .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() {
|
function initializeDisableVoteSubmission() {
|
||||||
chrome.storage.sync.get(["disableVoteSubmission"], (res) => {
|
chrome.storage.sync.get(["disableVoteSubmission"], (res) => {
|
||||||
handleDisableVoteSubmissionChangeEvent(res.disableVoteSubmission);
|
handleDisableVoteSubmissionChangeEvent(res.disableVoteSubmission);
|
||||||
|
|||||||
Reference in new issue
Block a user