Greasy Fork

Greasy Fork is available in English.

广州市中小学教师继续教育网刷课脚本

该油猴脚本用于 广州市中小学教师继续教育网 的辅助看课,脚本功能如下:webtrn.cn机构课程,自动点击确定;tt.cn机构课程,视频中间题目自动答题;yanxiu.com机构课程,视频中间题目自动答题

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         广州市中小学教师继续教育网刷课脚本
// @namespace    https://jiaobenmiao.com/
// @version      1.0
// @description  该油猴脚本用于 广州市中小学教师继续教育网 的辅助看课,脚本功能如下:webtrn.cn机构课程,自动点击确定;tt.cn机构课程,视频中间题目自动答题;yanxiu.com机构课程,视频中间题目自动答题
// @author       脚本喵
// @match        https://i.teacher.gzteacher.com/*
// @match        https://*.webtrn.cn/*
// @match        https://*.ttcn.cn/*
// @match        https://*.yanxiu.com/*
// @grant        none
// @icon         https://jiaobenmiao.com/img/logo2.jpg
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    // webtrn.cn机构课程,自动点击确定
    function kill_loop_click() {
        var time_out = 0;
        var count = 0;
        setInterval(() => {
            if (typeof document.getElementsByClassName("layui-layer-btn0")[0] != "undefined") {
                $(".layui-layer-btn0").trigger("click");
                console.log("Loop conform cracked [" + count + "] times.");
                time_out = 0;
                // document.getElementById("container_display").click();  # V 0.1 Bug code.
                if ($("#player_pause").css("display") != "none") { // # V 0.1.2  Bug fixed code
                    $("#player_pause").click();
                }
                count += 1;
            }
            console.log("Time elapsed [" + time_out + "s].");
            time_out += 1;
        }, 1000);
    }

    if (location.href.indexOf("webtrn.cn") != -1) {
        kill_loop_click();
    }

    // tt.cn机构课程,视频中间题目自动答题
    if (location.href.indexOf("ttcn.cn") != -1) {
        setInterval(function () {
            if (document.querySelector(".ant-modal-content") && document.querySelector(".ant-modal-content").querySelector("input")) {
                setTimeout(function () {
                    document.querySelector(".ant-modal-content").querySelector("input").click()
                }, 1000)

                setTimeout(function () {
                    document.querySelector(".ant-modal-content").querySelector("button").click()
                }, 2000)
            }

        }, 5 * 1000)
    }

    // yanxiu.com机构课程,视频中间题目自动答题
    if (location.href.indexOf("yanxiu.com") != -1) {
        setInterval(function () {

            if (document.querySelector(".question-stem")) {
                for (let i = 0; i < document.querySelectorAll(".question-stem").length; i++) {
                    let item = document.querySelectorAll(".question-stem")[i];
                    if (isElementVisible(item)) {
                        setTimeout(function () {
                            item.querySelector(".label-text").click()
                        }, 1000)

                        setTimeout(function () {
                            document.querySelectorAll(".question button.ivu-btn.ivu-btn-primary")[i].click()
                        }, 2000)

                        setTimeout(function () {
                            document.querySelectorAll(".question button.ivu-btn.ivu-btn-primary")[i].click()
                        }, 3000)

                    }
                }
            }

        }, 5 * 1000)
    }

    function isElementVisible(element) {
        // 首先检查传入的参数是否为Element对象
        if (!(element instanceof Element)) {
            console.error('The provided parameter is not an Element.');
            return false;
        }

        // 检查元素是否在DOM中
        if (!document.body.contains(element)) {
            return false;
        }

        // 获取元素的计算样式
        var style = window.getComputedStyle(element);

        // 检查元素的visibility属性
        if (style.visibility === 'hidden') {
            return false;
        }

        // 检查元素的opacity属性
        if (style.opacity === '0') {
            return false;
        }

        // 检查元素的尺寸
        if (element.offsetWidth === 0 || element.offsetHeight === 0) {
            return false;
        }

        // 获取元素的位置和尺寸
        var rect = element.getBoundingClientRect();
        if (rect.width === 0 || rect.height === 0) {
            return false;
        }

        // 检查元素是否在视口内
        if (rect.right < 0 || rect.bottom < 0 || rect.left > window.innerWidth || rect.top > window.innerHeight) {
            return false;
        }

        // 检查元素是否被其他元素遮挡
        while ((element = element.parentNode) && !document.body.contains(element)) {
            if (style['overflow'] === 'hidden') {
                var parentRect = element.getBoundingClientRect();
                if (rect.right < parentRect.left || rect.left > parentRect.right || rect.bottom < parentRect.top || rect.top > parentRect.bottom) {
                    return false;
                }
            }
        }

        // 如果所有检查都通过了,那么元素是可见的
        return true;
    }

})();