Automatically skip ads on Spotify.
// ==UserScript==
// @name Ad Skipper for Spotify Web Player
// @namespace http://tampermonkey.net/
// @version 1.2.0
// @description Automatically skip ads on Spotify.
// @author Tomoyuki Kawao
// @match https://open.spotify.com/*
// @license MIT
// @grant none
// @run-at document-start
// ==/UserScript==
document.createElement = function(originalCreateElement) {
return function() {
var element = originalCreateElement.apply(this, arguments);
if (element instanceof HTMLMediaElement) {
element.addEventListener("play", (event) => {
if (!event.currentTarget.src.startsWith("blob:https://open.spotify.com/") && event.currentTarget.duration < 40.0) {
let target = event.currentTarget;
setTimeout(() => {
target.currentTime = target.duration;
}, 1);
}
});
}
return element;
};
}(document.createElement);