soundcloud disable autoplay station (silent)

Silently disables Soundcloud Autoplay Station without UI changes

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         soundcloud disable autoplay station (silent)
// @version      2.0.0
// @description  Silently disables Soundcloud Autoplay Station without UI changes
// @author       bhackel (improved)
// @match        https://soundcloud.com/*
// @license      MIT
// @grant        none
// @run-at       document-idle
// @noframes
// @namespace    https://greasyfork.org/en/users/324178-bhackel
// ==/UserScript==

(function() {
'use strict';

// Check and disable autoplay without opening the queue UI
function silentDisable() {
    const toggle = document.querySelector('.queueFallback__toggle .sc-toggle');
    
    if (toggle && toggle.classList.contains('sc-toggle-on')) {
        // Create and dispatch a click event programmatically without UI interaction
        const event = new MouseEvent('click', {
            bubbles: true,
            cancelable: true,
            view: window
        });
        toggle.dispatchEvent(event);
    }
}

// Use MutationObserver to watch for DOM changes and catch autoplay re-enabling
const observer = new MutationObserver(() => {
    silentDisable();
});

// Wait for the queue element to exist in DOM (without opening it)
function waitForQueue() {
    const queueContainer = document.querySelector('.playControls__queue');
    
    if (queueContainer) {
        // Start observing for changes
        observer.observe(document.body, {
            childList: true,
            subtree: true,
            attributes: true,
            attributeFilter: ['class']
        });
        
        // Initial disable attempt
        silentDisable();
        
        // Periodic check as backup (every 3 seconds)
        setInterval(silentDisable, 3000);
    } else {
        // Queue not loaded yet, check again
        setTimeout(waitForQueue, 500);
    }
}

// Alternative approach: Intercept at a lower level if the toggle isn't in DOM
function forceDisableCheck() {
    // This runs regardless of whether queue is visible
    const toggle = document.querySelector('.queueFallback__toggle .sc-toggle');
    if (toggle && toggle.classList.contains('sc-toggle-on')) {
        toggle.click();
    }
}

// Start the script
waitForQueue();

// Backup periodic check (every 5 seconds)
setInterval(forceDisableCheck, 5000);

})();