Created
September 4, 2016 12:39
-
-
Save LoveIsGrief/dda1af62d96d37df6d650cf776882c53 to your computer and use it in GitHub Desktop.
Monkeyscript to scroll to the end of the likes, because soundclound doesn't allow random sort of the whole collection
This file contains 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 scroll | |
// @namespace http://userscripts.org/users/399688 | |
// @description Scroll to the end of the likes, because soundclound doesn't allow random sort of the whole collection | |
// @include https://soundcloud.com/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
/** | |
Script for soundclound that still hasn't implemented randomized playing of favorite tracks. | |
This will just continuously scroll to the end of the page when the button is hit and stop when hit again. | |
Yeah, the CSS sucks giant, monsterballs and it works like shit. So fucking what. It kinda, sorta works. | |
Made in Firefox's Ardoise. | |
**/ | |
var body = document.getElementsByTagName('body') [0]; | |
// Was a div before. It's now a button to trigger the functionality | |
var div = document.createElement('button'); | |
var interval = null; | |
div.id = 'autoscroller' | |
div.innerHTML = 'Start scrolling' | |
div.style = 'z-index: 9999; position: fixed; height: 45px; width: 110px; right: 0px; top: 0px; text-align: center;' | |
function activateDiv(){ | |
interval = setInterval(()=> { | |
// Will work until they rename the class | |
document.getElementsByClassName('l-footer')[0].scrollIntoView() | |
}, 500); | |
div.innerHTML = "Stop scrolling" | |
} | |
function deactivateDiv(){ | |
clearInterval(interval); | |
interval = null; | |
div.innerHTML = "Start scrolling" | |
} | |
div.addEventListener('click', (e)=> { | |
interval ? deactivateDiv() : activateDiv(); | |
}) | |
// Wait for the correct URL - add or remove | |
setInterval( ()=> { | |
var onLikesPage = window.location.href.startsWith("https://soundcloud.com/you/likes") | |
if(onLikesPage && !document.getElementById(div.id)) { | |
body.appendChild(div) | |
} else if(!onLikesPage && document.getElementById(div.id)){ | |
deactivateDiv() | |
body.removeChild(div) | |
} | |
}, 500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment