Plex auto-skip intro

Automatically press the Plex "Skip intro" button when it appears.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Plex auto-skip intro
// @namespace    https://greasyfork.org/en/users/555204-bcldvd
// @version      0.1
// @description  Automatically press the Plex "Skip intro" button when it appears.
// @author       Dustin Höfer
// @match        https://app.plex.tv/desktop
// @grant        none
// ==/UserScript==

(function() {
    let observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if(mutation.addedNodes.length > 0 && mutation.addedNodes[0]){
             var xpathResult = document.evaluate("(//text()[contains(., 'Skip Intro')])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
                var node=xpathResult.singleNodeValue;
                if (node!=null){
                    setTimeout(() => {
                        document.getElementsByClassName("AudioVideoFullPlayer-overlayButton-30Vz4v Button-button-2kT68l Link-link-2n0yJn Button-button-2kT68l Link-link-2n0yJn Button-default--yDCH5 Button-large-3S9UdJ Link-link-2n0yJn Link-default-2XA2bN     ")[0].click();
                }, 2000);
                }


            }
        });
    });
    observer.observe(element, { childList: true, subtree: true });
})();