Skip to content

Instantly share code, notes, and snippets.

@vincerubinetti
Last active April 19, 2025 03:09
Show Gist options
  • Save vincerubinetti/8e74900f0824d8d55b1247f0a5db312d to your computer and use it in GitHub Desktop.
Save vincerubinetti/8e74900f0824d8d55b1247f0a5db312d to your computer and use it in GitHub Desktop.
Run in dev console on Bandcamp album page to calculate length
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");
console.log(`🎬 ${tracks} tracks ⌛ ${hours}:${minutes}:${seconds} length`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment