Last active
May 23, 2017 03:14
-
-
Save deoxxa/bea10aa8f47202f3b6dcb48bb5f12c48 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
Paste this into your browser console on a bandcamp page and it'll replace the | |
track player listing with text, where the text has track start times and | |
names. This makes it easier to copy/paste track information about albums e.g. | |
for reviews. | |
You can use either the full version or the minified version. Both do the same | |
thing, but the minified one might be easier to paste. |
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
(function() { | |
let last = 0; | |
const arr = Array.from( | |
document.querySelectorAll( | |
'.track_list > tbody > tr > td.title-col > div.title' | |
) | |
) | |
.map(function(e) { | |
const time = e | |
.querySelector('.time') | |
.innerText.trim() | |
.split(':') | |
.map(function(e) { | |
return parseInt(e, 10); | |
}); | |
const s = last; | |
last += time[0] * 60 + time[1]; | |
const t = e.querySelector('a').innerText.trim(); | |
return { s, t }; | |
}) | |
.map(function(e) { | |
const { s, t } = e; | |
const bits = []; | |
if (last > 60 * 60) { | |
bits.push(Math.floor(s / 60 / 60).toString(10).padStart(2, '0')); | |
} | |
bits.push(Math.floor(s / 60 % 60).toString(10).padStart(2, '0')); | |
bits.push((s % 60).toString(10).padStart(2, '0')); | |
return `${bits.join(':')} ${t}`; | |
}); | |
document.querySelector( | |
'.track_table' | |
).outerHTML = `<pre>${arr.join('\n')}</pre>`; | |
})(); |
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
(function(){var t=0;var r=Array.from(document.querySelectorAll(".track_list > tbody > tr > td.title-col > div.title")).map(function(r){var e=r.querySelector(".time").innerText.trim().split(":").map(function(t){return parseInt(t,10)});var a=t;t+=e[0]*60+e[1];var n=r.querySelector("a").innerText.trim();return{s:a,t:n}}).map(function(r){var e=r.s,a=r.t;var n=[];if(t>60*60){n.push(Math.floor(e/60/60).toString(10).padStart(2,"0"))}n.push(Math.floor(e/60%60).toString(10).padStart(2,"0"));n.push((e%60).toString(10).padStart(2,"0"));return n.join(":")+" "+a});document.querySelector(".track_table").outerHTML="<pre>"+r.join("\n")+"</pre>"})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment