diff --git a/Update.json b/Update.json index 8674920b..09973f9b 100644 --- a/Update.json +++ b/Update.json @@ -2947,6 +2947,28 @@ } ], "Notes": "No release notes were provided for this release." + }, + "2.0.0": { + "UpdateDate": 1754724044036, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 826, + "Description": "修复更新" + } + ], + "Notes": "No release notes were provided for this release." + }, + "2.1.0": { + "UpdateDate": 1754724455081, + "Prerelease": false, + "UpdateContents": [ + { + "PR": 826, + "Description": "修复更新" + } + ], + "Notes": "No release notes were provided for this release." } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index 821a3aa6..f8c3a504 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 1.10.0 +// @version 2.1.0 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen @@ -39,7 +39,7 @@ */ const CaptchaSiteKey = "0x4AAAAAAALBT58IhyDViNmv"; -const AdminUserList = ["zhuchenrui2", "shanwenxiao", "admin"]; +const AdminUserList = ["zhuchenrui2", "shanwenxiao", "chenlangning", "admin"]; let escapeHTML = (str) => { return str.replace(/[&<>"']/g, function (match) { @@ -107,6 +107,24 @@ let GetRelativeTime = (Input) => { } } }; + +function compareVersions(currVer, remoteVer) { + const currParts = currVer.split('.').map(Number); + const remoteParts = remoteVer.split('.').map(Number); + + const maxLen = Math.max(currParts.length, remoteParts.length); + for (let i = 0; i < maxLen; i++) { + const curr = currParts[i] !== undefined ? currParts[i] : 0; + const remote = remoteParts[i] !== undefined ? remoteParts[i] : 0; + if (remote > curr) { + return true; // update needed + } else if (remote < curr) { + return false; // no update needed + } + } + return false; // versions are equal +} + let RenderMathJax = async () => { try { if (document.getElementById("MathJax-script") === null) { @@ -270,9 +288,6 @@ let GetUsernameHTML = async (Element, Username, Simple = false, Href = "https:// if (AdminUserList.includes(Username)) { HTMLData += `脚本管理员`; } - if (Username == "chenlangning") { - HTMLData += `吉祥物`; - } let BadgeInfo = await GetUserBadge(Username); if (BadgeInfo.Content != "") { HTMLData += `${BadgeInfo.Content}`; @@ -1031,7 +1046,7 @@ async function main() { break; } } - if (CurrentVersion < LatestVersion) { + if (compareVersions(CurrentVersion, LatestVersion)) { let UpdateDiv = document.createElement("div"); UpdateDiv.innerHTML = `