21. Nov 2020 |

Let the Spotify play your favourite songs by 30 seconds

Inspired by this article and the economic situation for musicians I wrote this little script. This lets Spotify to play your favourite artists on rotation and automatically presses “next” after every 33 (+ littlebit of random) seconds. 30 seconds is the minimum amount of time a song must be listened to before Spotify registers a single “play”.

Loading the song also takes little bit of time so you can not maximize the play count by making the loop take exactly 30 seconds long.

function getRandomInt(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min) + min);

function doSomething() {
    var button = document.querySelector('[aria-label="Next"]');

(function loop() {
    var rand = getRandomInt(33000, 37000);
    setTimeout(function() {
    }, rand);

If you are using Spotify in your browser the press ctrl+shift+k or just F12, open console tab, paste this code there and press enter. This code does nothing but pressing the button with title attribute “Next” after every 33-37 seconds (random between these times).

Example of how it works in browser.

It is one option to support your favourite artists 🙂

3 thoughts on “Let the Spotify play your favourite songs by 30 seconds”

  1. Script doesn’t work!
    I copied the code in Chrome & Firefox and get only an error code after a few seconds.

  2. Hi. I just tested and it works for me. I made this gif (in the post) to show you how to use it. Maybe helps. You need to start playing (some playlist preferably) and it just presses “next”.

  3. Hi Robert,

    Thanks for your reply!
    I tried the script again in Chrome & Firefox and still get the following error:

    Uncaught TypeError: button is null
    doSomething debugger eval code:8
    debugger eval code:14
    r https://open.scdn.co/cdn/build/web-player/vendor~web-player.e07a6039.js:1
    setTimeout handler*82303/ze</e.prototype._wrapTimeFunction/< https://open.scdn.co/cdn/build/web-player/vendor~web-player.e07a6039.js:1
    loop debugger eval code:13
    debugger eval code:17

    I’m doing exactly the same as described above and as the GIF shows, but keep getting the error. Could it be the browser?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.