Skip to content

Instantly share code, notes, and snippets.

@yutsuku
Last active January 3, 2018 22:14
Show Gist options
  • Save yutsuku/04bc7378a44d6177a83354743268b06f to your computer and use it in GitHub Desktop.
Save yutsuku/04bc7378a44d6177a83354743268b06f to your computer and use it in GitHub Desktop.
// ==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