Twitch Pause Carousel

Pause home page carousel

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Twitch Pause Carousel
// @namespace    https://github.com/dotmick/
// @version      0.2
// @description  Pause home page carousel
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @author       dotmick
// @match        *://www.twitch.tv
// @grant        none
// @license      GPL-3.0-or-later
// ==/UserScript==


// Ugly, but that works
$(document).ready(() => {
	console.log('Running Twitch Pause Carousel (TPC)');

    var checkExist = setInterval(function() {
        if ($('.video-player__container video').get(0).readyState == 4) {
            console.log("TPC – Video ready to be paused");
            clearInterval(checkExist);
            var nbPausing = 100;
            var forcePausing = setInterval(function() {
                console.log("TPC – Forcing pause...");
                $('.video-player__container video').get(0).pause();
                nbPausing--;
                if(nbPausing == 0)
                {
                    clearInterval(forcePausing);
                    console.log("TPC – Forcing pause done (x" + nbPausing + ")");
                }

            }, 100);
        }
    }, 100);
});