Bandcamp snatcher

Feeling good about this one

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Bandcamp snatcher
// @namespace    http://andrewiankidd.co.uk
// @version      0.1
// @description  Feeling good about this one
// @author       You
// @include      https://*.bandcamp.com/album/*
// @include      http://*.bandcamp.com/album/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

(function() {
    'use strict';
    console.log('----------starting bandcamp stuff: ');

    var regmatches = $('body').html().toString().match(new RegExp('\"\/\/(.*?)\"', 'g'));

    console.log('----------found ' + (regmatches.length - 1) + ' tracks' );

    i=0;
    $('#track_table > tbody  > tr').each(function() {
        if (i % 1 === 0){
            //alert('track: ' + i);
            $(this).prepend("<td><a download='Track " + i + ".mp3' href='" + regmatches[i].replace(new RegExp('"', 'g'), '') + "' style='display:inline;'><img style='height:16px;' src='http://i.imgur.com/RmhfNoM.png'></a></td>"); 
        }
        i=i+0.5;
    });
})();