node / whatcd gazelle torrent button

// ==UserScript==
// @name        whatcd gazelle torrent button
// @include     /https?://www\.empornium\.(me|sx)*/
// @version     3
// @require     http://code.jquery.com/jquery-2.1.1.js
// ==/UserScript==

// Changelog:
// * version 3
// - enabled jQuery.noConflict
// * version 2
// - fixed Sandbox page

this.jQuery = jQuery.noConflict(true);

(function() {

    var code = jQuery('a.bb_button[alt="Code"]');
    var target = code.attr('onclick').match(/'([^']*)'\)$/)[1];
    var torrent = code.clone();
    torrent.attr({
        'onclick': "tag('torrent', '" + target + "')",
        'title': "Torrent display: [torrent]torrent-id[/torrent]",
        'alt': "Torrent"
    });
    torrent.text("Torrent");
    code.after(" ", torrent);

})();