Merhaba, Yabancı!

Burada yeni gibi görünüyorsunuz. Eğer katılmak istiyorsanız düğmelerden birine tıklayınız.

Issue and possible solution

About: soundcloud disable autoplay station

The Next Up menu wasn't closing after Autoplay Station was disabled, so I took a look at the code. I'm no expert, but I figured since disableButtonLoop() is called only if buttonDiv exists, there's no need to loop it. I tried a simplified version of the script and it worked. Basically, I removed disableButtonLoop() and modified closeQueue() as below:

function closeQueue(queueTrigger) {
        // closes the Next Up queue once the Autoplay button has been disabled
        var buttonDiv = document.getElementsByClassName("queueFallback__toggle").item(0);
        if (buttonDiv) {
            // check if the button has loaded, then turn it off
            var button = buttonDiv.children.item(0);
            if (button.className === "toggle sc-toggle sc-toggle-active") {
                // it has this classname when Autoplay is enabled
                button.click();
            }
            queueTrigger.click();
        } else {
            // perform another check after delay
            setTimeout(function() { closeQueue(queueTrigger); }, 500);
        }
}

I hope this helps, please let me know if anything could've been done better.

Yorumlar

  • I'm having the same problem as well, but I tried your new function @J/K and it didn't help me. I'd really like to get this script working properly because the autoplay feature is really annoying.

    Any thoughts on this @bhackel?

  • September 20 düzenlendi [?]

    Tried this and it did work. The annoying thing though is that spacebar still won't work to pause the track unless you click in the webpage first. Maybe you could add a fix for this?

  • September 20 düzenlendi [?]

    @SUM1 Try replacing the closeQueue function with this (just a small change to give focus to the play button):

        function closeQueue(queueTrigger) {
            // closes the Next Up queue once the Autoplay button has been disabled
            var buttonDiv = document.getElementsByClassName("queueFallback__toggle").item(0);
            if (buttonDiv) {
                // check if the button has loaded, then turn it off
                var button = buttonDiv.children.item(0);
                if (button.className === "toggle sc-toggle sc-toggle-active") {
                    // it has this classname when Autoplay is enabled
                    button.click();
                }
                  queueTrigger.click();
                // give focus to the play button
                  document.getElementsByClassName("playButton").item(0).focus();
            } else {
                // perform another check after delay
                setTimeout(function() { closeQueue(queueTrigger); }, 500);
            }
        }
    
  • September 22 düzenlendi [?]

    @greasy-spork What exactly isn't working - the autoplay isn't being disabled or the Next Up menu isn't closing?

  • October 6 düzenlendi [?]

    Nice work guys, sorry for ghosting my project. @J/K the purpose of disableButtonLoop() is to continually disable the Autoplay Button while the user is on soundcloud. Using your modifications to the script, it does successfully disable the button, but only for the first track. If I click on a song in a different playlist, the button re-enables itself (super annoy), and the loop takes care of this.

    I'll look into the differences with the code that makes it so the Next Up menu closes properly. The original worked fine for me, so I'll try different computer configurations. For reference, can you tell me what browser and OS you are using?

    As for @SUM1 i'll implement the change made by @J/K

    @greasy-spork if you could provide more information on what is not working, like if the Next Up menu does not open and close or what else is broken, that would be very helpful in improving the script.

    edit: The way that disableButtonLoop repeatedly runs is by calling itself every 2 seconds. I'm unsure if this was clear or not.

  • @bhackel Thanks for the clarification - I didn't realize the setting could change after the page was loaded, probably because I tend to play only one song or playlist.

    I'm using Firefox 69 on Linux Mint. The problem (Next Up menu not closing) occurred inconsistently, like the browser was sometimes not ready for that part of the code.

    Maybe setting the script to run at "document-end" or "document-idle" would help - I'm gonna try that and see what happens.

  • @J/K I made some changes to the closeQueue function, now it should only attempt to close the Next Up menu if it is open. See if it works, in addition to changing when the script runs.

    function closeQueue(queueTrigger) {
        var buttonDiv = document.getElementsByClassName('queueFallback__toggle').item(0);
        var queueDiv = document.getElementsByClassName('playbackSoundBadge m-queueVisible');
    
        // check if the button has loaded and if the Next Up menu is open
        if (buttonDiv && queueDiv.length === 1) {
            queueTrigger.click(); // click to close the Next Up menu
            // Add focus back to the play/pause button
            document.getElementsByClassName('playButton').item(0).focus();
            disableButtonLoop(); // call the loop since the button has loaded
        } else {
            // perform another check after delay
            setTimeout(function() { closeQueue(queueTrigger); }, 500);
        }
    }`
    
  • @bhackel The code changes don't seem to make a difference in my tests, neither does running the script at document-end. However, running the script at document-idle (with or without the code changes) seems to solve the problem.

  • Interesting, thanks for the testing. I'll push an update with the change in run-at.

Yorum yapmak içinOturum Açın yada Kayıt Olun .