levelKro / Digitally Imported Music Downloader (Free Edition)

// ==UserScript==
// @name         Digitally Imported Music Downloader (Free Edition)
// @namespace    https://levelkro.com/
// @version      1.1.0
// @description  Download song files from the DI.FM website.
// @author       levelKro
// @match        https://*.di.fm/*
// @grant        none
// @noframes
// @run-at       document-idle
// @license      MIT
// @updateURL    https://openuserjs.org/meta/levelKro/Digitally_Imported_Music_Downloader_(Free_Edition).meta.js
// @copyright    2019, levelKro (https://levelkro.com) (https://openuserjs.org/users/levelKro)
// ==/UserScript==
/*** YOU CAN CHANGE SETTINGS HERE ***/
var buttonRefresh=100; //Refresh of button
var diDebug=true; //Only for debugging.


/*** HALT - STOP - DO NOT CONTINU ***/
/*** DO NOT CHANGE SETTING HERE ***/
// FileSaver Script (MIN) from https://github.com/eligrey/FileSaver.js
(function(a,b){if("function"==typeof define&&define.amd)define([],b);else if("undefined"!=typeof exports)b();else{b(),a.FileSaver={exports:{}}.exports}})(this,function(){"use strict";function b(a,b){return"undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(b,c,d){var e=new XMLHttpRequest;e.open("GET",b),e.responseType="blob",e.onload=function(){a(e.response,c,d)},e.onerror=function(){console.error("could not download file")},e.send()}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send()}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0,a=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href)},4E4),setTimeout(function(){e(j)},0))}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else{var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i)})}}:function(a,b,d,e){if(e=e||open("","_blank"),e&&(e.document.title=e.document.body.innerText="downloading..."),"string"==typeof a)return c(a,b,d);var g="application/octet-stream"===a.type,h=/constructor/i.test(f.HTMLElement)||f.safari,i=/CriOS\/[\d]+/.test(navigator.userAgent);if((i||g&&h)&&"object"==typeof FileReader){var j=new FileReader;j.onloadend=function(){var a=j.result;a=i?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),e?e.location.href=a:location=a,e=null},j.readAsDataURL(a)}else{var k=f.URL||f.webkitURL,l=k.createObjectURL(a);e?e.location=l:location.href=l,e=null,setTimeout(function(){k.revokeObjectURL(l)},4E4)}});f.saveAs=a.saveAs=a,"undefined"!=typeof module&&(module.exports=a)});
//# sourceMappingURL=FileSaver.min.js.map
var chkSong="";
var chkSongArtist="";
var chkSongTitle="";
var chkSongUrl="";
var chkSongUrlVerif="";
var Song="";
var SongUrl="";
var saveTrack=JSON.parse("{}");
var savePlaylist=JSON.parse("{}");
var aStr="DI.FM Downloader [ ";
var bStr=" ]";
var imgDown="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iNTEyIiB2aWV3Qm94PSItMjAgMCA0NDggNDQ4IiB3aWR0aD0iNTEyIiBjbGFzcz0iIj48Zz48cGF0aCBkPSJtMjI0IDI4MGMwIDguODM1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1OTMgMi4wMDM5MDcgMS41MTE3MTkgMy4xNzk2ODggMy44Nzg5MDcgMy4xNzk2ODggNi4zODY3MTl2MTM2YzAgMTcuNjcxODc1LTE0LjMyODEyNSAzMi0zMiAzMnMtMzItMTQuMzI4MTI1LTMyLTMyIDE0LjMyODEyNS0zMiAzMi0zMmM1LjYzMjgxMi4wMzEyNSAxMS4xNTYyNSAxLjU3MDMxMiAxNiA0LjQ0OTIxOXYtNjUuODM5ODQ0bC05NiAyNy40Mjk2ODd2OTcuOTYwOTM4YzAgMTcuNjcxODc1LTE0LjMyODEyNSAzMi0zMiAzMnMtMzItMTQuMzI4MTI1LTMyLTMyIDE0LjMyODEyNS0zMiAzMi0zMnptMCAwIiBkYXRhLW9yaWdpbmFsPSIjMDAwMDAwIiBjbGFzcz0iYWN0aXZlLXBhdGgiIHN0eWxlPSJmaWxsOiM1QUE3RkYiIGRhdGEtb2xkX2NvbG9yPSIjMDAwMDAwIj48L3BhdGg+PC9nPiA8L3N2Zz4=";

const __send = XMLHttpRequest.prototype.send;
console.log(aStr+"Starting up."+bStr);
var outputStyles='<style>.difmBox { font-size:10px; line-height:12px; min-height:24px;    bottom: 64px;    border: 1px solid #3165ae;    border-radius: 0 8px 0 0;    left: 0;    z-index: -1;    position: fixed;    background: linear-gradient(to bottom left,#444d6a,#2e354a);    display: block;    padding: 8px 8px 5px 5px; white-space:nowrap;} .difmBox img {float:left; margin:0 -24px 0 0; width:24px; height:24px;} .difmBox span { display:block; margin:0 0 0 30px} .difmBox b { font-weight:bold; color:#fff;} #difmStatus b { color:#5986f7; } .difmBox input { opacity:1; float:right; height:12px; display:block; padding:0; margin:0; position:relative;} .difmBox label { float:right;position:relative; padding:0; margin:0 5px;}</style>';
document.getElementsByClassName("preferences-region")[0].innerHTML+=outputStyles+'<div class="difmBox"><a class="ico" id="difmDown" onclick="alert(\'Sorry, no song found, you listen with the web player ?\');" title="Download not ready" style="cursor:pointer;"><img src="'+imgDown+'" width=24 height=24/></a><input type="checkbox" id="difmAuto" name="difmAuto"/><label for="difmAuto" title="When a new song is detected, the file is downloaded without user request. Need to be activate each time you connect to Di.FM website. If download not start, verify if your browser block download. (Chrome make this)">Auto-download</label><span><b>DI.FM Downloader</b></span><span id="difmStatus">Click play or select a music channel to begin.</span></div>';
XMLHttpRequest.prototype.send = function () {
    this.addEventListener('loadend', e => {
        if(document.getElementsByClassName("status")[0].innerText!="Stopped" && document.getElementsByClassName("artist-name").length>=1 && document.getElementsByClassName("track-name").length>=1){
            // Check current request
            if(e.target.responseURL.search(".di.fm/")!="-1"){
                // OK, this is from di.fm, working with response
                var re=e.target.response;
                if(re=="" || re==" ") {
                    // Empty answer, skip it!
                }
                else if(e.target.responseURL.search("channel/")!="-1"){
                    // Channel information, try to get playlist and current file details
                    if(diDebug) console.log(aStr+"Save channel details."+bStr);
                    savePlaylist=JSON.parse(re);
                }
                else if(e.target.responseURL.search("tracks/")!="-1"){
                    // Track details, try to get update details
                    if(diDebug) console.log(aStr+"Save track details."+bStr);
                    saveTrack=JSON.parse(re);
                }
                else {
                    // Unkown output, ignore it
                    if(diDebug) console.log('intercepted', e.target.responseURL);
                    //console.log('answer', "'"+e.target.response+"'");
                }
            }
        }
    }, {once: true});
    __send.apply(this, arguments);
};

setInterval(function () {
    var chkme="";
    if(document.getElementsByClassName("status")[0].innerText!="Stopped" && document.getElementsByClassName("artist-name").length>=1 && document.getElementsByClassName("track-name").length>=1){
        chkSongArtist=document.getElementsByClassName("artist-name")[0].innerText;
        chkSongTitle=document.getElementsByClassName("track-name")[0].innerText;
        chkSong=chkSongArtist+chkSongTitle;
        chkSong=chkSong.replace("  "," ");
        var chkFind=false;
        if(chkSong!=Song && chkSong!=""){
            if(diDebug) console.log(aStr+"New song detected."+bStr);
            for (var z in savePlaylist.tracks){
                // working on available playlist
                chkme=savePlaylist.tracks[z].display_artist+" - "+savePlaylist.tracks[z].display_title;
                chkme=chkme.replace("  "," ");
                if(diDebug) console.log(aStr+"Saved Playlist #"+z+" : "+chkme+""+bStr);
                if(chkme==chkSong) {
                    // This is the current song, great, update details
                    if(diDebug) console.log(aStr+" '-This is the new song, update cache details."+bStr);
                    Song=chkSong;
                    SongUrl=savePlaylist.tracks[z].content.assets[0].url;
                    chkFind=true;
                }
            }
            if(!chkFind){
                chkme=saveTrack.display_artist+" - "+saveTrack.display_title;
                chkme=chkme.replace("  "," ");
                if(diDebug) console.log(aStr+"Saved Track : "+chkme+""+bStr);
                if(chkme==chkSong) {
                    // This is the current song, great, update details
                    if(diDebug) console.log(aStr+"The cached track is the current, update details."+bStr);
                    Song=chkSong;
                    SongUrl=saveTrack.content.assets[0].url;
                    chkFind=true;
                }
            }
            //Apply changes
            if(chkFind){
                if(diDebug) console.log(aStr+"Update button with new details."+bStr);
                document.getElementById("difmDown").onclick = function() {console.log(aStr+"Downloading file, please wait."+bStr); alert("Downloading file in background, you see the song audio file for '"+Song+"' in the download folder when is done."); saveAs(SongUrl,Song.replace(":","-")+".m4a");};
                document.getElementById("difmDown").title="Download '"+Song+"' now!";
                document.getElementById("difmStatus").innerHTML="Download link for <b>"+Song+"</b> is ready.";
                if(document.getElementById("difmAuto").checked==true) {
                    if(diDebug) console.log(aStr+"Auto download the new track."+bStr);
                    var tmpFile=Song.replace(":","-")+".m4a";
                    setTimeout("saveAs(\""+SongUrl+"\",\""+tmpFile+"\");",1000);
                }
            }
            else {
                if(diDebug) console.log(aStr+"Disable download button."+bStr);
                savePlaylist="";
                saveTrack="";
                document.getElementById("difmDown").onclick = function() {alert("Sorry, the url of the current song "+chkSong+" can't be found. You can try to change channel and go back if is not find after few seconds.");};
                document.getElementById("difmDown").title="Current song link is not detected!";
                document.getElementById("difmStatus").innerHTML="Unable to detect the current song.";
            }
        }
        else {
            //Nothing to do, song not changed
        }
    }
    else {
        //Wait the user to start player, or paused, or adroll is playing
    }
},buttonRefresh);

console.log(aStr+"Debug mode: "+((diDebug) ? "enabled":"disabled") +"."+bStr);
console.log(aStr+"Refresh: "+buttonRefresh+"ms."+bStr);
console.log(aStr+"Ready to monitoring."+bStr);