2024寒假研修,点击播放就通过(刷新一下)

自动静音视频,模拟视频播放结束

目前為 2024-02-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name    2024寒假研修,点击播放就通过(刷新一下)
// @namespace http://tampermonkey.net/
// @version 0.3
// @license V+Adxm2023
// @description 自动静音视频,模拟视频播放结束
// @author   安得闲门
// @match https://basic.smartedu.cn/*
// @match https://www.smartedu.cn/*
// @match https://teacher.vocational.smartedu.cn/*
// @match https://core.teacher.vocational.smartedu.cn/*
// ==/UserScript==
(function() {
    'use strict';
setInterval(function() {
var v = document.getElementsByTagName('video')[0];
if (v) {
v.currentTime = v.duration;
}
}, 1000);
    function runCodeInPage(code) {
        var script = document.createElement('script');
        script.textContent = code;
        (document.head || document.documentElement).appendChild(script);
        // 由于在插入文档后立即执行并移除,这里无需手动调用remove方法
        // script.remove();
    }

    document.addEventListener('click', function(event) {
        if (event.button === 0) {
            setTimeout(function() {
                runCodeInPage(`
                    var videoElement = document.querySelector("video");
                    if (videoElement) {
                        videoElement.dispatchEvent(new Event("ended"));
                        videoElement.muted = true;
                        videoElement.playbackRate = 1.8;
                        videoElement.play();
                    }
                `);
            }, 200);
        }
    });
})();