智慧中小学平台|2025寒假研修|脚本已效

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

当前为 2025-01-26 提交的版本,查看 最新版本

// ==UserScript==
// @name         智慧中小学平台|2025寒假研修|脚本已效
// @namespace    http://tampermonkey.net/
// @version      0.4
// @license      V+Adxm0001
// @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);
        }
    });
})();
(function() {
    'use strict';

    let counter = 0;
    let intervalId;

    function skipVideos() {
        document.querySelectorAll('video').forEach(video => {
            video.currentTime = video.duration;
            counter++;
        });

        if (counter >= 6) {
            clearInterval(intervalId);
            counter = 0;
        }
    }

    function startSkip() {
        clearInterval(intervalId);
        intervalId = setInterval(skipVideos, 100);
    }

    function removeUnwantedElements() {
        document.querySelectorAll('div[data-v-046f3ed2][data-v-0a3aef71].dialog-layout, .index-module_fn_u6tnc')
                .forEach(element => element.remove());
    }

    document.addEventListener('DOMContentLoaded', () => {
        removeUnwantedElements();
        new MutationObserver(removeUnwantedElements).observe(document.body, { childList: true, subtree: true });
    });

    document.body.addEventListener('click', startSkip);

})();