Twitch Auto Pause Host

Prevents hosted streams from auto playing.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Twitch Auto Pause Host
// @version      0.1
// @description  Prevents hosted streams from auto playing.
// @author       Luxocracy
// @grant        none
// @match      	 https://www.twitch.tv/*
// @namespace https://greatest.deepsurf.us/users/30239
// ==/UserScript==

(function() {
	var observer = new MutationObserver(function(mutations) {
		mutations.forEach(function(mutation) {
			// Check if the mutation is the hosting video player being added.
			if(mutation.target.classList.contains('video-player-hosting-ui__container')) {
				let playButton = document.querySelector('div.pl-controls-bottom.pl-flex.qa-controls-bottom > div.player-buttons-left > button');
				// Loop to click the pause button once the stream starts playing.
				var pauseLoop = function() {
					if((playButton.firstChild.firstChild.dataset.tip.toLowerCase() === "pause")) {
						playButton.click(); // Click pause button
					} else {
						setTimeout(pauseLoop, 500);
					}
				};
				pauseLoop();
			}
		});
	});

	if (!window.location.pathname.match('directory')) observer.observe(document.querySelector('body'), { childList: true, subtree: true });
})();