Skip to content

Commit

Permalink
fix: 修复代码长度单位换算错误
Browse files Browse the repository at this point in the history
  • Loading branch information
boomzero committed Nov 25, 2024
1 parent a9d85e8 commit 6eb87a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Binary file added ._.idea
Binary file not shown.
Binary file added ._XMOJ.user.js
Binary file not shown.
24 changes: 23 additions & 1 deletion XMOJ.user.js
Original file line number Diff line number Diff line change
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

0 comments on commit 6eb87a2

Please sign in to comment.