Created
June 26, 2023 17:09
-
-
Save eai04191/96baa0407df9db0a4ba3fef10f4475b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ArkWindowsSize() { | |
const units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]; | |
function toBytes(sizeStr) { | |
const [value, unit] = sizeStr.split(" "); | |
return Number(value) * Math.pow(1024, units.indexOf(unit)); | |
} | |
function fromBytes(bytes) { | |
let unitIndex = 0; | |
while (bytes >= 1024 && unitIndex < units.length - 1) { | |
bytes /= 1024; | |
unitIndex++; | |
} | |
return `${bytes.toFixed(2)} ${units[unitIndex]}`; | |
} | |
const totalBytes = [ | |
...document.querySelectorAll("#depots table .octicon-windows"), | |
] | |
.map((e) => e.closest("tr").querySelector("td:last-of-type")) | |
.filter((e) => e.className === "") | |
.map((e) => toBytes(e.innerText)) | |
.reduce((a, b) => a + b, 0); | |
return fromBytes(totalBytes); | |
} | |
ArkWindowsSize(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment