延河课堂播放增强

点击视频空白处切换播放暂停,左右方向键控制5秒快进快退,上下方向键切换2倍速和原速

目前為 2021-11-10 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         延河课堂播放增强
// @namespace    https://www.ordosx.tech/
// @version      1.2
// @description  点击视频空白处切换播放暂停,左右方向键控制5秒快进快退,上下方向键切换2倍速和原速
// @author       OrdosX
// @match        https://www.yanhekt.cn/session/*
// @icon         https://www.google.com/s2/favicons?domain=yanhekt.cn
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    window.addEventListener('load', () => {
        main()
    })
    const main = () => {
        if (!(document.querySelector(".main-player video") && document.querySelector(".player-panel") && document.querySelector(".player-mask"))) {
            setTimeout(main, 20)
        } else {
            document.querySelector(".player-panel").onclick = () => {
                document.querySelector(".controller-panel .head-container button").click()
            }
            document.querySelector(".player-mask").onclick = () => {
                document.querySelector(".controller-panel .head-container button").click()
            }
            document.querySelector(".main-player video").onratechange = () => {
                document.querySelector(".playback-rates-text").innerText = `${document.querySelector(".main-player video").playbackRate.toFixed(1)}X`
            }
            document.onkeydown = (e) => {
                e.preventDefault()
                switch(e.keyCode){
                    case 37: // 左方向键快退五秒
                        document.querySelector(".main-player video").currentTime -= 5
                        break
                    case 39: // 右方向键快进5秒
                        document.querySelector(".main-player video").currentTime += 5
                        break
                    case 38: // 上方向键2倍速
                        document.querySelectorAll('video').forEach((e)=>{e.playbackRate = 2})
                        break
                    case 40: // 下方向键原速
                        document.querySelectorAll('video').forEach((e)=>{e.playbackRate = 1})
                        break
                    case 32: // 空格暂停
                        document.querySelector(".controller-panel .head-container button").click()
                        break
                }
            }
        }
    }
})();