Last active
December 10, 2019 18:12
-
-
Save yukikaoru/f40c7d9a3a8c7ac635fd282cec1fb699 to your computer and use it in GitHub Desktop.
Twitchトップページのカルーセルの自動再生を自動停止する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Twitch carousel auto pause | |
// @version 1.4 | |
// @description Twitchトップページの自動再生を自動停止する | |
// @author YUKI Kaoru | |
// @match https://www.twitch.tv/* | |
// @grant none | |
// ==/UserScript== | |
function pauseVideo() { | |
const intervalId = setInterval(() => { | |
const video = document.querySelector('.video-player video') | |
if (video) { | |
video.addEventListener('loadeddata', () => { | |
document.querySelector('.video-player button[data-a-target="player-play-pause-button"]').click() | |
video.removeEventListener('loadeddata', clickPauseButton) | |
}) | |
clearInterval(intervalId) | |
} | |
}, 100) | |
} | |
(() => { | |
'use strict'; | |
if (location.toString().match(/www.twitch.tv\/?$/)) { | |
pauseVideo() | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment