Created
March 15, 2021 16:40
-
-
Save JustGAST/0b58da48ccddc9f6bd18a4559cec0898 to your computer and use it in GitHub Desktop.
Get cloud.mail.ru folder sum size
This file contains 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
// ==UserScript== | |
// @name cloud.mail.ru folder size sum | |
// @description Shows folder sum size in Mb for russian locale | |
// @match *://cloud.mail.* | |
// ==/UserScript== | |
const getSizeInMb = (size) => { | |
switch (true) { | |
case size.includes('МБ'): | |
return parseFloat(size.substring(0, size.length - 3)); | |
case size.includes('ГБ'): | |
return parseFloat(size.substring(0, size.length - 3)) * 1024; | |
case size.includes('КБ'): | |
return parseFloat(size.substring(0, size.length - 3)) / 1024; | |
case size.includes('байт'): | |
return parseFloat(size.substring(0, size.length - 5)) / 1024 / 1024; | |
} | |
} | |
$(document).ready(function() { | |
setTimeout(function() { | |
const sizeElems = $('[class^=DataListItemRow__size]'); | |
let sumSize = 0; | |
$.each(sizeElems, (i, elem) => { | |
sumSize += getSizeInMb(elem.textContent); | |
}); | |
$("[class^='FilesCounter']")[0].innerHTML += ', ' + sumSize.toFixed(2) + ' МБ'; | |
}, 1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment