Skip to content

Commit 13058b6

Browse files
authored
Merge pull request #827 from XMOJ-Script-dev/dev
Release
2 parents b789bf2 + ed758de commit 13058b6

3 files changed

Lines changed: 44 additions & 7 deletions

File tree

Update.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,6 +2947,28 @@
29472947
}
29482948
],
29492949
"Notes": "No release notes were provided for this release."
2950+
},
2951+
"2.0.0": {
2952+
"UpdateDate": 1754724044036,
2953+
"Prerelease": true,
2954+
"UpdateContents": [
2955+
{
2956+
"PR": 826,
2957+
"Description": "修复更新"
2958+
}
2959+
],
2960+
"Notes": "No release notes were provided for this release."
2961+
},
2962+
"2.1.0": {
2963+
"UpdateDate": 1754724455081,
2964+
"Prerelease": false,
2965+
"UpdateContents": [
2966+
{
2967+
"PR": 826,
2968+
"Description": "修复更新"
2969+
}
2970+
],
2971+
"Notes": "No release notes were provided for this release."
29502972
}
29512973
}
29522974
}

XMOJ.user.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name XMOJ
3-
// @version 1.10.0
3+
// @version 2.1.0
44
// @description XMOJ增强脚本
55
// @author @XMOJ-Script-dev, @langningchen and the community
66
// @namespace https://github/langningchen
@@ -39,7 +39,7 @@
3939
*/
4040

4141
const CaptchaSiteKey = "0x4AAAAAAALBT58IhyDViNmv";
42-
const AdminUserList = ["zhuchenrui2", "shanwenxiao", "admin"];
42+
const AdminUserList = ["zhuchenrui2", "shanwenxiao", "chenlangning", "admin"];
4343

4444
let escapeHTML = (str) => {
4545
return str.replace(/[&<>"']/g, function (match) {
@@ -107,6 +107,24 @@ let GetRelativeTime = (Input) => {
107107
}
108108
}
109109
};
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+
110128
let RenderMathJax = async () => {
111129
try {
112130
if (document.getElementById("MathJax-script") === null) {
@@ -270,9 +288,6 @@ let GetUsernameHTML = async (Element, Username, Simple = false, Href = "https://
270288
if (AdminUserList.includes(Username)) {
271289
HTMLData += `<span class="badge text-bg-danger ms-2">脚本管理员</span>`;
272290
}
273-
if (Username == "chenlangning") {
274-
HTMLData += `<span class="badge ms-2" style="background-color: #6633cc; color: #ffffff">吉祥物</span>`;
275-
}
276291
let BadgeInfo = await GetUserBadge(Username);
277292
if (BadgeInfo.Content != "") {
278293
HTMLData += `<span class="badge ms-2" style="background-color: ${BadgeInfo.BackgroundColor}; color: ${BadgeInfo.Color}">${BadgeInfo.Content}</span>`;
@@ -1031,7 +1046,7 @@ async function main() {
10311046
break;
10321047
}
10331048
}
1034-
if (CurrentVersion < LatestVersion) {
1049+
if (compareVersions(CurrentVersion, LatestVersion)) {
10351050
let UpdateDiv = document.createElement("div");
10361051
UpdateDiv.innerHTML = `
10371052
<div class="alert alert-warning alert-dismissible fade show mt-2" role="alert">

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xmoj-script",
3-
"version": "1.10.0",
3+
"version": "2.1.0",
44
"description": "an improvement script for xmoj.tech",
55
"main": "AddonScript.js",
66
"scripts": {

0 commit comments

Comments
 (0)