Skip to content

Instantly share code, notes, and snippets.

@vincerubinetti
Created February 23, 2021 04:08
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 vincerubinetti/8e74900f0824d8d55b1247f0a5db312d to your computer and use it in GitHub Desktop.
Save vincerubinetti/8e74900f0824d8d55b1247f0a5db312d to your computer and use it in GitHub Desktop.
// go to Bandcamp album page, open dev console (f12), paste and run
function get() {
const rows = document.querySelectorAll("tr.track_row_view");
let tracks = 0;
let hours = 0;
let minutes = 0;
let seconds = 0;
for (const row of rows) {
time = row.querySelector(".time")?.innerText;
if (time && time.includes(":")) {
tracks++;
minutes += parseInt(time.split(":")[0]);
seconds += parseInt(time.split(":")[1]);
}
}
minutes += Math.floor(seconds / 60);
seconds = seconds % 60;
hours = Math.floor(minutes / 60);
minutes = minutes % 60;
hours = String(hours).padStart(2, "0");
minutes = String(minutes).padStart(2, "0");
seconds = String(seconds).padStart(2, "0");
return `🎬 ${tracks} tracks ⌛ ${hours}:${minutes}:${seconds} length`;
}
get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment