brijeshb42 / Netflix/PrimeVideo Autoskip

// ==UserScript==
// @name         Netflix/PrimeVideo Autoskip
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       brijeshb42
// @match        https://www.netflix.com/*
// @match        https://www.primevideo.com/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var intervalID;
    var className = location.host.indexOf('primevideo') >= 0 ? '.skipElement' : '.skip-credits a';

    function skip() {
        const link = document.querySelector(className);
        if (link) {
            link.click();
            stop();
            setTimeout(start, 10000);
        }
    }

    function start() {
        intervalID = setInterval(skip, 1000);
    }

    function stop() {
        clearInterval(intervalID);
    }

    start();
})();