ROBLOX Soundloader

Download songs from ROBLOX!

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         ROBLOX Soundloader
// @namespace    RBLXSNDLDR
// @version      2.1
// @description  Download songs from ROBLOX!
// @author       SFOH
// @match        http://www.roblox.com/*
// @grant        none
// ==/UserScript==

var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
var isChrome = !!window.chrome && !isOpera;
var isFirefox = typeof InstallTrigger !== 'undefined'; //just for robloxian4545 because he uses firefox like a CHUMP

function downloadURI(uri,name) { //allows user to download the asset
    var link = document.createElement("a");
    link.download = name;
    link.href = uri;
    if(isChrome){
        alert("Warning! If the file doesn't play - it may be an .ogg! Try renaming it if it doesn't work.");
        link.click();
    } else {
        alert("Warning! You will have to press Ctrl+S to save this file! (try chrome?)");
        var event = document.createEvent("MouseEvents"); //stolen as fuck
        event.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
        link.dispatchEvent(event);
    };
};

function createDownloadBtn(pElement,type,uri){ //where pElement is the frame to add the button to
    if(type==="audio"){
        var b = document.createElement("input");
        b.setAttribute("class","downloadButton");
        b.setAttribute("type","image");
		b.setAttribute("src","http://vavvi.com/images/2015/06/a99x0ghdgnfv9ls16rww.png");
        b.setAttribute("style","background-position:0px 0px;display:inline-block;background:url(http://vavvi.com/images/2015/06/ncrr1l5xcu0qbyvwwzye.png) 0px 0px;border:0;margin:0;padding:0;cursor:pointer;color:transparent;position:relative;background-repeat:no-repeat;width:25px;height:25px;left:-25px;top:-25px;z-index:9");
        b.onclick=function(){
            downloadURI(uri,".mp3");
        }
        b.onmouseenter=function(){
            b.setAttribute("style","background-position:-25px 0px;display:inline-block;background:url(http://vavvi.com/images/2015/06/ncrr1l5xcu0qbyvwwzye.png) -25px 0px;border:0;margin:0;padding:0;cursor:pointer;color:transparent;position:relative;background-repeat:no-repeat;width:25px;height:25px;left:-25px;top:-25px;z-index:9")
        }
        b.onmouseleave=function(){
            b.setAttribute("style","background-position:0px 0px;display:inline-block;background:url(http://vavvi.com/images/2015/06/ncrr1l5xcu0qbyvwwzye.png) 0px 0px;border:0;margin:0;padding:0;cursor:pointer;color:transparent;position:relative;background-repeat:no-repeat;width:25px;height:25px;left:-25px;top:-25px;z-index:9")
        }
        pElement.appendChild(b);
    }
}

function assetPuller(){
    var objects = document.getElementsByClassName("MediaPlayerIcon Play");
    for(var i = 0;i < objects.length;i++){
        var playbutton = objects[i];
        var parent = playbutton.parentElement;
        var asseturi = playbutton.getAttribute("data-mediathumb-url");
        createDownloadBtn(parent,"audio",asseturi);
    }
}

function checkForUpdates(){
    if(!document.getElementsByClassName("downloadButton").length>0){
       assetPuller();
    }
}

setInterval(checkForUpdates,500)