Last active
January 3, 2018 22:14
-
-
Save yutsuku/04bc7378a44d6177a83354743268b06f to your computer and use it in GitHub Desktop.
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 Stop auto play | |
// @version 1.2 | |
// @author moh <moh@yutsuku.net> | |
// @include https://soundcloud.com/*/* | |
// @include https://soundcloud.com/*/sets/* | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function waitForAddedNode(params) { | |
new MutationObserver(function(mutations) { | |
var el = document.querySelector(params.element); | |
if (el) { | |
this.disconnect(); | |
params.done(el); | |
} | |
}).observe(document, { | |
subtree: true, | |
childList: true, | |
}); | |
} | |
// click on autostation if active, close menu | |
waitForAddedNode({ | |
element: '.queueFallback__stationMode .toggle.sc-toggle.sc-toggle-active', | |
done: function(el) { | |
el.click(); | |
var e = document.querySelector('.playbackSoundBadge__showQueue'); | |
if (e) { | |
e.click(); | |
} | |
} | |
}); | |
// open menu so soundcloud can build DOM | |
waitForAddedNode({ | |
element: '.playbackSoundBadge__showQueue', | |
done: function(el) { | |
el.click(); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment