diff --git a/._.idea b/._.idea new file mode 100644 index 00000000..7ebf9cdf Binary files /dev/null and b/._.idea differ diff --git a/._XMOJ.user.js b/._XMOJ.user.js new file mode 100644 index 00000000..7ebf9cdf Binary files /dev/null and b/._XMOJ.user.js differ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 45570f86..e16f678d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,6 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit fetch-depth: 0 # a full history is required for pull request analysis - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2024.1 + uses: JetBrains/qodana-action@v2024.3 env: QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} diff --git a/Update.json b/Update.json index 2992dfee..13f16985 100644 --- a/Update.json +++ b/Update.json @@ -2644,6 +2644,43 @@ } ], "Notes": "No release notes were provided for this release." + }, + "1.2.71": { + "UpdateDate": 1732545478542, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 753, + "Description": "fix: 修复代码长度单位换算错误" + } + ], + "Notes": "No release notes were provided for this release." + }, + "1.2.72": { + "UpdateDate": 1738077477956, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 758, + "Description": "Fix #714" + } + ], + "Notes": "No release notes were provided for this release." + }, + "1.2.73": { + "UpdateDate": 1738925550389, + "Prerelease": false, + "UpdateContents": [ + { + "PR": 753, + "Description": "fix: 修复代码长度单位换算错误" + }, + { + "PR": 758, + "Description": "Fix #714" + } + ], + "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 8c77db53..b1be1f7a 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 1.2.70 +// @version 1.2.73 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen @@ -215,7 +215,7 @@ let GetUserBadge = async (Username) => { */ let GetUsernameHTML = async (Element, Username, Simple = false, Href = "https://www.xmoj.tech/userinfo.php?user=") => { try { - Username = Username.replaceAll(/[^a-zA-Z0-9]/g, ""); + //Username = Username.replaceAll(/[^a-zA-Z0-9]/g, ""); let ID = "Username-" + Username + "-" + Math.random(); Element.id = ID; Element.innerHTML = `
`; @@ -340,6 +340,28 @@ let SizeToStringSize = (Memory) => { } } }; +let CodeSizeToStringSize = (Memory) => { + try { + if (UtilityEnabled("AddUnits")) { + if (Memory < 1024) { + return Memory + "B"; + } else if (Memory < 1024 * 1024) { + return (Memory / 1024).toFixed(2) + "KB"; + } else if (Memory < 1024 * 1024 * 1024) { + return (Memory / 1024 / 1024).toFixed(2) + "MB"; + } else { + return (Memory / 1024 / 1024 / 1024).toFixed(2) + "GB"; + } + } else { + return Memory; + } + } catch (e) { + console.error(e); + if (UtilityEnabled("DebugMode")) { + SmartAlert("XMOJ-Script internal error!\n\n" + e + "\n\n" + "If you see this message, please report it to the developer.\nDon't forget to include console logs and a way to reproduce the error!\n\nDon't want to see this message? Disable DebugMode."); + } + } +}; /** * Converts a time value to a string representation. * @param {number} Time - The time value to convert. @@ -1836,7 +1858,7 @@ async function main() { Temp[i].childNodes[3].childNodes[0].innerText = SizeToStringSize(Temp[i].childNodes[3].childNodes[0].innerText); Temp[i].childNodes[4].childNodes[0].innerText = TimeToStringTime(Temp[i].childNodes[4].childNodes[0].innerText); Temp[i].childNodes[5].innerText = Temp[i].childNodes[5].childNodes[0].innerText; - Temp[i].childNodes[6].innerText = SizeToStringSize(Temp[i].childNodes[6].innerText.substring(0, Temp[i].childNodes[6].innerText.length - 1)); + Temp[i].childNodes[6].innerText = CodeSizeToStringSize(Temp[i].childNodes[6].innerText.substring(0, Temp[i].childNodes[6].innerText.length - 1)); Temp[i].childNodes[9].innerText = (Temp[i].childNodes[9].innerText == "" ? "否" : "是"); } if (SearchParams.get("cid") === null) { diff --git a/package.json b/package.json index b41cd6a6..a150a192 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "1.2.70", + "version": "1.2.73", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": {