Skip to content

Instantly share code, notes, and snippets.

@dcpesses
Last active November 9, 2023 16:05
Show Gist options
  • Save dcpesses/a19c771b169bb7e5a4c5c90bdb40d6e5 to your computer and use it in GitHub Desktop.
Save dcpesses/a19c771b169bb7e5a4c5c90bdb40d6e5 to your computer and use it in GitHub Desktop.
Spotify 30ish Skip
/*
Plays the first 30-40 seconds of each song in your Spotify queue.
Intended to fix your personalized suggestions when someone else uses your account
Based on https://do.that.ee/let-the-spotify-play/
To use:
Login to Spotify in your web browser.
Open your browser's JavaScript Console.
Copy and execute the code below code.
Wait.
*/
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min);
}
function clickNext() {
document.querySelector('[data-testid="control-button-skip-forward"]').click();
}
window.enableAutoNext = true; //escape hatch
(function loop() {
var rand = getRandomInt(33000, 37000);
//console.log(rand);
setTimeout(function() {
var playBtn = document.querySelector('[data-testid="control-button-playpause"][aria-label="Play"]');
if (window.enableAutoNext && !playBtn) {
clickNext();
}
loop();
}, rand);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment