Skip to content

Instantly share code, notes, and snippets.

@JustGAST
Created March 15, 2021 16:40
Show Gist options
  • Save JustGAST/0b58da48ccddc9f6bd18a4559cec0898 to your computer and use it in GitHub Desktop.
Save JustGAST/0b58da48ccddc9f6bd18a4559cec0898 to your computer and use it in GitHub Desktop.
Get cloud.mail.ru folder sum size
// ==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