Created
February 23, 2021 04:08
-
-
Save vincerubinetti/8e74900f0824d8d55b1247f0a5db312d to your computer and use it in GitHub Desktop.
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
// 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