|
1 | 1 | // ==UserScript== |
2 | 2 | // @name XMOJ |
3 | | -// @version 1.10.0 |
| 3 | +// @version 2.1.0 |
4 | 4 | // @description XMOJ增强脚本 |
5 | 5 | // @author @XMOJ-Script-dev, @langningchen and the community |
6 | 6 | // @namespace https://github/langningchen |
|
39 | 39 | */ |
40 | 40 |
|
41 | 41 | const CaptchaSiteKey = "0x4AAAAAAALBT58IhyDViNmv"; |
42 | | -const AdminUserList = ["zhuchenrui2", "shanwenxiao", "admin"]; |
| 42 | +const AdminUserList = ["zhuchenrui2", "shanwenxiao", "chenlangning", "admin"]; |
43 | 43 |
|
44 | 44 | let escapeHTML = (str) => { |
45 | 45 | return str.replace(/[&<>"']/g, function (match) { |
@@ -107,6 +107,24 @@ let GetRelativeTime = (Input) => { |
107 | 107 | } |
108 | 108 | } |
109 | 109 | }; |
| 110 | + |
| 111 | +function compareVersions(currVer, remoteVer) { |
| 112 | + const currParts = currVer.split('.').map(Number); |
| 113 | + const remoteParts = remoteVer.split('.').map(Number); |
| 114 | + |
| 115 | + const maxLen = Math.max(currParts.length, remoteParts.length); |
| 116 | + for (let i = 0; i < maxLen; i++) { |
| 117 | + const curr = currParts[i] !== undefined ? currParts[i] : 0; |
| 118 | + const remote = remoteParts[i] !== undefined ? remoteParts[i] : 0; |
| 119 | + if (remote > curr) { |
| 120 | + return true; // update needed |
| 121 | + } else if (remote < curr) { |
| 122 | + return false; // no update needed |
| 123 | + } |
| 124 | + } |
| 125 | + return false; // versions are equal |
| 126 | +} |
| 127 | + |
110 | 128 | let RenderMathJax = async () => { |
111 | 129 | try { |
112 | 130 | if (document.getElementById("MathJax-script") === null) { |
@@ -270,9 +288,6 @@ let GetUsernameHTML = async (Element, Username, Simple = false, Href = "https:// |
270 | 288 | if (AdminUserList.includes(Username)) { |
271 | 289 | HTMLData += `<span class="badge text-bg-danger ms-2">脚本管理员</span>`; |
272 | 290 | } |
273 | | - if (Username == "chenlangning") { |
274 | | - HTMLData += `<span class="badge ms-2" style="background-color: #6633cc; color: #ffffff">吉祥物</span>`; |
275 | | - } |
276 | 291 | let BadgeInfo = await GetUserBadge(Username); |
277 | 292 | if (BadgeInfo.Content != "") { |
278 | 293 | HTMLData += `<span class="badge ms-2" style="background-color: ${BadgeInfo.BackgroundColor}; color: ${BadgeInfo.Color}">${BadgeInfo.Content}</span>`; |
@@ -1031,7 +1046,7 @@ async function main() { |
1031 | 1046 | break; |
1032 | 1047 | } |
1033 | 1048 | } |
1034 | | - if (CurrentVersion < LatestVersion) { |
| 1049 | + if (compareVersions(CurrentVersion, LatestVersion)) { |
1035 | 1050 | let UpdateDiv = document.createElement("div"); |
1036 | 1051 | UpdateDiv.innerHTML = ` |
1037 | 1052 | <div class="alert alert-warning alert-dismissible fade show mt-2" role="alert"> |
|
0 commit comments