Greasy Fork

Greasy Fork is available in English.

深信服在线课堂之自动学习

自动进入下一任务

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         深信服在线课堂之自动学习
// @namespace    http://tampermonkey.net/
// @version      20240304143716
// @description  自动进入下一任务
// @author       wwsuixin
// @match        https://learning.sangfor.com.cn/course/*
// @icon         https://learning.sangfor.com.cn/files/system/2019/01-17/2110339c5d49156533.ico?version=5.1.7&jcversion=20240111
// @grant        none
// ==/UserScript==

(function () {

    window.onload = setTimeout(click_item, 500);
    function click_item() {
        var video = document.getElementById('lesson-player_html5_api');
        setInterval(function () {

            if (video) { // 确保成功获取到video元素
                video.playbackRate = 2;
                video.play();
            }

            // 使用XPath选择目标元素
            var xpath = "/html/body/div[2]/div[1]/div[3]/div[3]/span";
            var result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);

            // 判断元素class值中是否包含"open"
            if (result.singleNodeValue && (result.singleNodeValue.classList.contains("open") || result.singleNodeValue.classList.contains("moveup"))) {
            var content = result.singleNodeValue.getAttribute("data-content");
            var regex = /<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/g;
            var match = regex.exec(content);

            if (match) {
                var link = match[2];
                console.log("提取到的超链接: " + link);
                window.location.href = link
            } else {
                console.log("未找到超链接");
            }
            } else {
                console.log("未找到匹配的元素或class值中不包含'open'");
            }

        }, 5000)
    }
})();