adds a link that triggers buy for $0; set format to FLAC and click download. multiple purchases get a "download all" link (wait for them to process before using)
目前為
// ==UserScript==
// @name BC: do free downloads
// @namespace userscript1
// @match https://*.bandcamp.com/*
// @match https://*.bandcamp.com/*
// @match https://bandcamp.com/download
// @grant none
// @version 0.2.2
// @author -
// @license GPLv3
// @description adds a link that triggers buy for $0; set format to FLAC and click download. multiple purchases get a "download all" link (wait for them to process before using)
// ==/UserScript==
(function() {
'use strict';
const emailaddress = ''; // put your email here
function $(s) {
return document.querySelector(s);
}
// release page -------------------------------------
function startFreeDownload() {
$('button.buy-link').click();
setTimeout(function() {
var elm = $('#userPrice');
elm.value='0';
var event = new UIEvent("change", {
"view": window,
"bubbles": true,
"cancelable": true
});
elm.dispatchEvent(event);
}, 300);
setTimeout(function() {
$('.download-panel-free-download-link').click();
}, 1000);
setTimeout(function() {
if ($('#downloadButtons_download').style.display != 'none') {
console.log('email not required, clicking OK');
$('#downloadButtons_download button.download-panel-checkout-button').click();
} else {
console.log('email required');
$('#fan_email_postalcode').value = '1';
$('#fan_email_address').focus();
if (emailaddress) {
$('#fan_email_address').value = emailaddress;
$('#downloadButtons_download button.download-panel-checkout-button').click();
}
}
}, 1500);
}
var elm = $('#trackInfoInner');
if (elm && elm.textContent.includes('name your price') ) {
$('li.buyItem').insertAdjacentHTML(
'beforeEnd',
'<h4><a id="StartFreeDownload">Start free download >></a></h4>'
);
$('#StartFreeDownload').addEventListener('click', startFreeDownload);
}
// end release page -------------------------------------
// download page -------------------------------------
function downloadWhenReady() {
var links = document.querySelectorAll('span.download-title a.item-button');
if (links[0] && links[0].style.display != 'none' && links[0].textContent.includes('Download') ) {
if (links.length == 1) {
console.log('clicking download');
link.click();
} else {
$('div.download-extras').insertAdjacentHTML('beforeBegin',
`<div style="text-align: right;">
[<a id="DownloadThemAll">Download them all</a>]
</div>`);
$('#DownloadThemAll').addEventListener('click', downloadThemAll);
}
} else {
console.log('waiting for download');
setTimeout(downloadWhenReady, 1000);
}
}
function downloadThemAll() {
var links = document.querySelectorAll('span.download-title a.item-button');
for (let link of links) {
var frame = document.createElement('iframe');
frame.src = link.href;
document.body.appendChild(frame);
}
}
elm = $('div.item-format');
if (elm && !elm.textContent.includes('FLAC') ) {
setTimeout(function() {
elm.click();
$('.formats > li:nth-child(3)').click();
}, 500);
}
if (elm) {
setTimeout(downloadWhenReady, 2000);
}
// end download page -------------------------------------
})();