Skip to content

Commit a71a5fb

Browse files
committed
full show download support
1 parent 5f3dc60 commit a71a5fb

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

content.js

+36-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@ function click(event) {
55
httpGetAsync("http://www.livephish.com/bigriver/subPlayer.aspx?HLS=1&callback=angular.callbacks._9&trackID=" + trackID, download);
66
}
77

8+
async function clickAll(event) {
9+
var downloadButtons = document.getElementsByClassName("downloadTrack");
10+
for(var i = 0; i < downloadButtons.length; i++) {
11+
var trackID = downloadButtons[i].parentNode.getAttribute("id");
12+
trackID = String.prototype.replace.call(trackID, "track-", "");
13+
await httpGetAsync("http://www.livephish.com/bigriver/subPlayer.aspx?HLS=1&callback=angular.callbacks._9&trackID=" + trackID, download);
14+
await Wait();
15+
}
16+
}
17+
18+
819
/* parses the response text, and downloads the file */
920
function download(responseText)
1021
{
1122
var dlLink = String.prototype.substring.call(responseText, 36);
1223
dlLink = String.prototype.split.call(dlLink, '\"')[0];
13-
1424
var link = document.createElement("a");
1525
link.download = "song.m4a";
1626
link.href = dlLink;
@@ -21,13 +31,25 @@ function download(responseText)
2131
delete link;
2232
}
2333

34+
async function Wait() {
35+
console.log('Taking a break...');
36+
await sleep(2000);
37+
console.log('Two second later');
38+
}
39+
40+
function sleep(ms) {
41+
return new Promise(resolve => setTimeout(resolve, ms));
42+
}
43+
2444
/* Gets the page which contains our download link */
2545
function httpGetAsync(theUrl, callback)
2646
{
2747
var xmlHttp = new XMLHttpRequest();
2848
xmlHttp.onreadystatechange = function() {
2949
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
50+
{
3051
callback(xmlHttp.responseText);
52+
}
3153
}
3254
xmlHttp.open("GET", theUrl, true); // true for asynchronous
3355

@@ -40,12 +62,24 @@ window.onload = function(){
4062

4163
for(var i = 0;i < rows.length; i++) {
4264
var button = document.createElement("button");
43-
var textNode = document.createTextNode("download");
65+
var textNode = document.createTextNode("Download track");
4466
button.setAttribute("id", "download_" + i);
67+
button.setAttribute("class", "downloadTrack")
4568
button.setAttribute("href", "javascript:void(0)");
4669
button.setAttribute("style", "margin-left: 5px; margin-top: 5px;");
4770
button.appendChild(textNode);
4871
rows[i].insertBefore(button, rows[i].childNodes[0]);
4972
button.addEventListener('click', click);
5073
}
74+
75+
playSection = document.getElementsByClassName("recording-controls")[0];
76+
var button = document.createElement("button");
77+
var textNode = document.createTextNode("Download Release");
78+
button.setAttribute("id", "downloadAll_" + i);
79+
button.setAttribute("href", "javascript:void(0)");
80+
button.setAttribute("style", "margin-left: 5px; margin-top: 5px;");
81+
button.appendChild(textNode);
82+
playSection.insertBefore(button, playSection.childNodes[0]);
83+
button.addEventListener('click', clickAll);
84+
5185
};

0 commit comments

Comments
 (0)