Skip to content

Instantly share code, notes, and snippets.

@yukikaoru
Last active December 10, 2019 18:12
Show Gist options
  • Save yukikaoru/f40c7d9a3a8c7ac635fd282cec1fb699 to your computer and use it in GitHub Desktop.
Save yukikaoru/f40c7d9a3a8c7ac635fd282cec1fb699 to your computer and use it in GitHub Desktop.
Twitchトップページのカルーセルの自動再生を自動停止する
// ==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