课堂派增强

看互动课件时,可用左右箭头翻页代替鼠标点击;看回放时,点击视频实现播放暂停

当前为 2022-03-29 提交的版本,查看 最新版本

// ==UserScript==
// @name         课堂派增强
// @namespace    http://tampermonkey.net/
// @version      2.2
// @description  看互动课件时,可用左右箭头翻页代替鼠标点击;看回放时,点击视频实现播放暂停
// @author       han
// @match        https://www.ketangpai.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ketangpai.com
// @grant        unsafeWindow
// @license      MIT

// ==/UserScript==
(function() {
    //实现左右箭头翻页
    //https://www.ketangpai.com/#/coursewareStudy?interactid=*
    document.addEventListener('keyup', function(e) {
        console.log();

        if (e.keyCode == 37) {
            //document.getElementsByClassName('.el-icon-caret-left')[0].click();
            document.querySelector('.el-icon-caret-left').click();
            //console.log("上一页");
        }

        if (e.keyCode == 39) {
            // document.getElementsByClassName('.right')[0].click();
            document.querySelector('.el-icon-caret-right').click();
            //console.log("下一页");
        }

        //console.log("1");
    });
})();

(function() {
    //https://www.ketangpai.com/#/resource_detail?courseid=*
    //实现点击视频区域播放暂停
    //延时函数等待dom元素,js,视频的加载
    setTimeout(() => {
        document.getElementById("vjs_video_3").addEventListener("click",function(c){//在视频区添加click事件监听
            //alert("暂停");
            //console.log("ok");
            var event =c||window.event;//获取事件对象
            var target =event.target||event.srcelement;
            if(!(document.getElementsByClassName("vjs-icon-placeholder")[0].contains(target))&&!(document.getElementsByClassName("vjs-control-bar")[0].contains(target))){//点击区域不为进度条和暂停键
                //console.log("判断点击区域");
                playpause();}
        })
    }, 4000);//延时4秒,可自己修改,单位ms
})();
//播放暂停函数
function playpause() {
    //console.log('暂停函数作用');
    if (document.querySelector("video").paused) {
        document.querySelector("video").play();
    } else { document.querySelector("video").pause(); }
}


QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址