Skip to content

Instantly share code, notes, and snippets.

@davidlacarta
Created February 19, 2019 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidlacarta/ab3a96f68e1aa78ba8f548d20210c33e to your computer and use it in GitHub Desktop.
Save davidlacarta/ab3a96f68e1aa78ba8f548d20210c33e to your computer and use it in GitHub Desktop.
[...document.getElementsByClassName("a-t-J a-Wa-ka l-oi-cc l-t-Q a-t-J-yl")]
.map(element => {
const sizeTextSplit = element.childNodes[3].childNodes[0].childNodes[1].childNodes[0].innerText.split(
" "
);
return {
size: Number(sizeTextSplit[0]),
unit: sizeTextSplit[1],
node: element
};
})
.map(element => {
const SIZES_KB = { MB: 1024, GB: 1048576, KB: 1 };
return {
size: element.size * SIZES_KB[element.unit],
unit: element.unit,
node: element.node
};
})
.reduce((sum, element) => sum + element.size, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment