Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复代码长度单位换算错误 #753

Merged
merged 7 commits into from
Nov 25, 2024
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
Binary file added ._.idea
Binary file not shown.
Binary file added ._XMOJ.user.js
Binary file not shown.
11 changes: 11 additions & 0 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -2644,6 +2644,17 @@
}
],
"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 change: 0 additions & 1 deletion Update/AutoLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const LabelList = [
"dependency",
"designing",
"documentation",
"docs",
"duplicate",
"discussing",
"enhancement",
Expand Down
26 changes: 24 additions & 2 deletions XMOJ.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name XMOJ
// @version 1.2.70
// @version 1.2.71
// @description XMOJ增强脚本
// @author @XMOJ-Script-dev, @langningchen and the community
// @namespace https://github/langningchen
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
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.2.70",
"version": "1.2.71",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
"scripts": {
Expand Down