Greasy Fork

Auto hide next up card for Amazon Prime Video

Auto hide next up card for Amazon Prime Video.

目前为 2023-11-02 提交的版本。查看 最新版本

// ==UserScript==
// @name         Auto hide next up card for Amazon Prime Video
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @description  Auto hide next up card for Amazon Prime Video.
// @author       ryo-fujinone
// @match        https://*.amazon.co.jp/gp/video/*
// @match        https://*.amazon.co.jp/Amazon-Video/*
// @match        https://*.amazon.com/*
// @match        https://*.amazon.ae/*
// @match        https://*.amazon.co.uk/*
// @match        https://*.amazon.it/*
// @match        https://*.amazon.in/*
// @match        https://*.amazon.eg/*
// @match        https://*.amazon.com.au/*
// @match        https://*.amazon.nl/*
// @match        https://*.amazon.ca/*
// @match        https://*.amazon.sa/*
// @match        https://*.amazon.sg/*
// @match        https://*.amazon.se/*
// @match        https://*.amazon.es/*
// @match        https://*.amazon.de/*
// @match        https://*.amazon.com.tr/*
// @match        https://*.amazon.com.br/*
// @match        https://*.amazon.fr/*
// @match        https://*.amazon.com.be/*
// @match        https://*.amazon.pl/*
// @match        https://*.amazon.com.mx/*
// @match        https://*.amazon.cn/*
// @match        https://*.primevideo.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const config = {childList: true, subtree: true};

    const observer = new MutationObserver((_, outerObserver) => {
        const wrapper = document.querySelector(".atvwebplayersdk-nextupcard-wrapper");
        if (!wrapper) return;

        // The wrapper will not be regenerated even if you move to the next episode or close and reopen the video.
        outerObserver.disconnect();

        new MutationObserver((_) => {
            wrapper.style.display = "none";
            const hideButton = wrapper.querySelector(".atvwebplayersdk-nextupcardhide-button")
            if (hideButton) {
                hideButton.click();
            }
        }).observe(wrapper, config);
    });

    observer.observe(document, config);
})();