Last active
March 29, 2020 21:49
-
-
Save Cauterite/3d1a3eceaf71100c03c52e6942d4e0d8 to your computer and use it in GitHub Desktop.
SoundCloud: Download Button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name SoundCloud: Download Button | |
// @namespace e7fc358c1e5cc159ce3f327246807caa | |
// @include https://soundcloud.com/* | |
// @version 1.1 | |
// @grant none | |
// @run-at document-idle | |
// ==/UserScript== | |
(function() { | |
`use strict`; | |
let More = document.querySelector(`.sc-button-more`); | |
if (!document.querySelector(`.moreActions`)) { | |
More.dispatchEvent(new MouseEvent(`click`, {})); /* open */ | |
}; | |
let Dl = document.querySelector(`.sc-button-download`); | |
More.dispatchEvent(new MouseEvent(`click`, {})); /* close */ | |
if (!Dl) {return; /* no download button */}; | |
let Dl2 = More.cloneNode(); | |
// Dl2.classList.add(`sc-button-download`); // breaks stuff | |
Dl2.classList.remove(`sc-button-more`); | |
Dl2.innerHTML = `Download`; | |
More.parentNode.insertBefore(Dl2, More); | |
Dl2.addEventListener(`click`, function(Ev) { | |
if (!document.querySelector(`.moreActions`)) { | |
More.dispatchEvent(new MouseEvent(`click`, {})); /* open */ | |
}; | |
Dl = document.querySelector(`.sc-button-download`); | |
Dl.dispatchEvent(new MouseEvent(`click`, {})); | |
More.dispatchEvent(new MouseEvent(`click`, {})); /* close */ | |
}, true); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment