Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}
27 changes: 21 additions & 6 deletions XMOJ.user.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -270,9 +288,6 @@ let GetUsernameHTML = async (Element, Username, Simple = false, Href = "https://
if (AdminUserList.includes(Username)) {
HTMLData += `<span class="badge text-bg-danger ms-2">脚本管理员</span>`;
}
if (Username == "chenlangning") {
HTMLData += `<span class="badge ms-2" style="background-color: #6633cc; color: #ffffff">吉祥物</span>`;
}
let BadgeInfo = await GetUserBadge(Username);
if (BadgeInfo.Content != "") {
HTMLData += `<span class="badge ms-2" style="background-color: ${BadgeInfo.BackgroundColor}; color: ${BadgeInfo.Color}">${BadgeInfo.Content}</span>`;
Expand Down Expand Up @@ -1031,7 +1046,7 @@ async function main() {
break;
}
}
if (CurrentVersion < LatestVersion) {
if (compareVersions(CurrentVersion, LatestVersion)) {
let UpdateDiv = document.createElement("div");
UpdateDiv.innerHTML = `
<div class="alert alert-warning alert-dismissible fade show mt-2" role="alert">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xmoj-script",
"version": "1.10.0",
"version": "2.1.0",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
"scripts": {
Expand Down