Skip to content

Instantly share code, notes, and snippets.

@erm3nda
Last active January 19, 2017 14:41
Show Gist options
  • Save erm3nda/61a57e99f2839a21bb5f to your computer and use it in GitHub Desktop.
Save erm3nda/61a57e99f2839a21bb5f to your computer and use it in GitHub Desktop.
Enables autoplay for SoundCloud via userscript. Just cuz i bored doing a click everytime i join...
// ==UserScript==
// @name soundcloud autoplay
// @author erm3nda at gmail.com
// @author-www http://erm3nda.github.io
// @post-www http://erm3nda.github.io/2016/04/28/soundcloud-autoplay-gm-userscript.html
// @namespace souncloud-autoplay
// @icon http://files.softicons.com/download/social-media-icons/simple-icons-by-dan-leech/png/32x32/soundcloud.png
// @description Does autoplay first track of given category
// @include https://soundcloud.com/*
// @include https://soundcloud.com/charts/top/*
// @version 1.0.1
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
// @todo randomize category if not defined in this file
// ==/UserScript==
//~ var category = "" // set blank for trending-music
var category="electronic" // <---------- define category here
var url_cat="?genre=" + category
// var category="alternative+rock"
$( document ).ready(function() {
console.log( "ready!" );
if (document.URL == "https://soundcloud.com/stream") {
window.location.href = "https://soundcloud.com/charts/top" + url_cat
}
if (document.URL == "https://soundcloud.com/charts/top" + url_cat) {
setTimeout(function() {
buttons = document.getElementsByClassName("sc-button-play")
play = buttons[0]
play.click()
console.log("Playing ...")
}, 5000)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment