Greasy Fork

来自缓存

Greasy Fork is available in English.

[Fixed] SoundCloud DL

Download SoundCloud tracks as mp3!

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         [Fixed] SoundCloud DL
// @namespace    SCDL
// @version      1.7.5
// @description  Download SoundCloud tracks as mp3!
// @author       Kıraç Armağan Önal
// @match        https://soundcloud.com/*
// @match        https://soundcloud.com/*/*
// @match        https://soundcloud.com/*/*/*
// @match        https://soundcloud.com/*/*/*/*
// @grant        unsafeWindow
// ==/UserScript==

(function() {
    "use strict";

    var OPTIONS = {
        /* true or false */
        autodownload: false,
        autoplay: false
    }

    /* don't change */
    var isLoaded = false;


    function createElementByHTML(html) {
    var divElm = document.createElement("div");
    divElm.innerHTML = html;
    return divElm.firstElementChild;
    };

    function loadSCDL(event) {
        if (isLoaded) return;
        isLoaded = true;
     setInterval(function(){
     if (!document.querySelector("#scdl-download-btn")) {
         var button_list = document.querySelector(".sc-button-group.sc-button-group-medium");
         if (button_list) button_list.appendChild(createElementByHTML(`<a id="scdl-download-btn" title="Download with SCDL!" href="javascript:openSCDL()"> <button class=" sc-button" alt="Download with SCDL">⬇ Download ⬇</button></a>`));
         unsafeWindow.openSCDL = function (){
           var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX;
             var dualScreenTop = window.screenTop != undefined ? window.screenTop : window.screenY;

             var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
             var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;

             var left = ((width / 2) - (1000 / 2)) + dualScreenLeft;
             var top = ((height / 2) - (1000 / 2)) + dualScreenTop;
             var newWindow = window.open(`https://soundcloud-dl.glitch.me/?autoplay=${OPTIONS.autoplay}&autodownload=${OPTIONS.autodownload}&url=${window.location.href}`, "SCDLWindow", 'width=1000, height=1000, top=' + top + ', left=' + left);

             if (window.focus) {
                 newWindow.focus();
             }
         }
     }
     },5000)
     }
    unsafeWindow.loadSCDL = loadSCDL;
    if (document.readyState == "loading") {
      document.addEventListener("DOMContentLoaded", (e)=>{loadSCDL(e)})
      document.addEventListener("DomContentLoaded", (e)=>{loadSCDL(e)})
    } else {
      loadSCDL();
    }

})();