xmoj-script 1.10.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Update.json +11 -0
- package/XMOJ.user.js +21 -6
- package/package.json +1 -1
package/Update.json
CHANGED
@@ -2947,6 +2947,17 @@
|
|
2947
2947
|
}
|
2948
2948
|
],
|
2949
2949
|
"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."
|
2950
2961
|
}
|
2951
2962
|
}
|
2952
2963
|
}
|
package/XMOJ.user.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// ==UserScript==
|
2
2
|
// @name XMOJ
|
3
|
-
// @version
|
3
|
+
// @version 2.0.0
|
4
4
|
// @description XMOJ增强脚本
|
5
5
|
// @author @XMOJ-Script-dev, @langningchen and the community
|
6
6
|
// @namespace https://github/langningchen
|
@@ -39,7 +39,7 @@
|
|
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
|
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">
|