From 06bcd1653f59033e9bd94f8ffd2f7177814df26d Mon Sep 17 00:00:00 2001 From: aiden Date: Fri, 18 Feb 2022 03:54:30 +0000 Subject: [PATCH] this was painful --- README.md | 2 ++ scdl.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 README.md create mode 100755 scdl.js diff --git a/README.md b/README.md new file mode 100755 index 0000000..e8887b1 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# scdl +it's gonna be a firefox browser extension that allows you to download playing soundcloud songs diff --git a/scdl.js b/scdl.js new file mode 100755 index 0000000..1a9b515 --- /dev/null +++ b/scdl.js @@ -0,0 +1,50 @@ +/* + ISC License + + Copyright (c) 2022, aiden (aiden@cmp.bz) + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +function scdl() { + if (typeof scdl.c == "undefined") { + scdl.c = 0n; + } + let key = "scdl" + Math.floor(Math.random() * 0x100000000).toString(0x10).padStart(8, "0") + scdl.c++; + let fuck = true; + webpackJsonp.push([[], { [key]: function (_, __, r) { + if (fuck) { + fuck = false; + return; + } + for (let idx = 0; typeof scdl.f == "undefined"; ++idx) { + let obj = r(idx); + if ("getCurrentSound" in obj) { + scdl.f = obj; + } + } + let player = scdl.f.getCurrentSound().player.player._player._controllerManager._cacheManager._players.find(e => e._playlistSegmentRetriever != null); + if (!player) { + return alert("Play a song."); + } + let segments = player._playlistSegmentRetriever._segments; + if (player._playlist._data.segments.length != segments.length) { + return alert("Song not fully downloaded yet."); + } + let u8_arrays = []; + for (let idx = 0; idx < segments.length; ++idx) { + u8_arrays.push(segments[idx].dataRetrieveJob._jobControl.progressUpdates.getProgressSoFar().data); + } + alert("issa " + player._transmuxerAndMimeType.mimeType); + location = URL.createObjectURL(new Blob(u8_arrays, { type: "application/octet-stream" })); + } }, [[key]]]); +}