您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Stops twitch autoplay on main page
// ==UserScript== // @name TwitchTV stop autoplay // @namespace PoKeRGT // @version 1.0 // @description Stops twitch autoplay on main page // @author PoKeRGT // @match https://www.twitch.tv/ // @icon https://www.google.com/s2/favicons?sz=64&domain=twitch.tv // @grant none // @run-at document-ready // @homepageURL https://github.com/PoKeRGT/userscripts // @license MIT // ==/UserScript== (function () { 'use strict'; console.info('Init TwitchTV stop autoplay') const playButtonAttribute = { "name": "data-a-player-state", "value": "playing" } const featuredItemXPath = "//div[@data-test-selector='featured-item-video']" const playButtonXPath = "//button[@data-a-target='player-play-pause-button']" function getElementByXpath(path, from) { return document.evaluate(path, from, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; } const observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { mutation.addedNodes.forEach(function (node) { if (node.nodeName === 'DIV') { const featuredVideo = getElementByXpath(featuredItemXPath, node) if (featuredVideo) { const playButton = getElementByXpath(playButtonXPath, featuredVideo) if (playButton && playButton.getAttribute(playButtonAttribute["name"]) === playButtonAttribute["value"]) { playButton.click() console.log('Stopped autoplay') } } } }); }); }); observer.observe(document, { childList: true, subtree: true }); })();