Bandcamp snatcher

Feeling good about this one

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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;
    });
})();