nl / Asbook.net Downloader

// ==UserScript==
// @name         Asbook.net Downloader
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  This script add ability to download .mp3 from the Asbook.net library.
// @author       nl
// @match        http://asbook.net/*
// @updateURL    https://openuserjs.org/meta/nl/Asbook.net_Downloader.meta.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // get and parse playlist url
    if ($('#playlistcode')){
        var playlistUrl = $('#playlistcode')
        .children()
        .find('param[name="flashvars"]')
        .val()
        .replace('st=http://asbook.net/player/audio.txt&pl=','');
        $.getJSON(playlistUrl, onPlaylist);
    }

    function onPlaylist(data){
        var items = [];
        // build download items list
        $.each( data.playlist, function( index, value ) {
            items.push( "<li><a class='item' href='" + value.file + "' download></i>" + value.comment + "</a></li>");
        });

        // insert downloader block
        $( "<div/>", {
            "class": "cell",
            "style" : "height: 100px;overflow:auto;",
            html: items.join( "" )
        }).insertBefore( $(".b-fullpost__data_rating").parent() );

        // Cleanup user data
        $(".b-fullpost__data_rating").remove();
        //$(".bcontents").remove();
        //$(".b-fullpost__userdata").remove();
    }
})();