智慧职教自动签到

因为当时公选课总是多次签到,且经常忘记签到,所以写了一个简单的脚本用于自动签到,防止漏签。

// ==UserScript==
// @name         智慧职教自动签到
// @namespace    https://rensr.site
// @version      0.1
// @description  实现智慧职教自动签到
// @author       任尚仁
// @match        *://*.icve.com.cn/*
// @icon         https://spoc-classroom.icve.com.cn/classroom/favicon.ico
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 创建操作日志记录元素和标题元素
    var logDiv = document.createElement('div');
    logDiv.id = 'log-div';
    // 添加滚动条样式
    logDiv.style.overflow = 'auto';
    logDiv.style.position = 'fixed';
    logDiv.style.top = '150px';
    logDiv.style.right = '5%';
    logDiv.style.transform = 'translateX(-50%)';
    logDiv.style.height = "150px";
    logDiv.style.width = "150px";
    logDiv.style.padding = '10px';
    logDiv.style.backgroundColor = '#ffffff';
    logDiv.style.border = '1px solid #cccccc';
    logDiv.style.boxShadow = '0px 2px 4px rgba(0, 0, 0, 0.1)';
    logDiv.style.zIndex = '9999';

    var titleElement = document.createElement('h3');
    titleElement.innerText = "日志";
    titleElement.style.textAlign = 'center';

    // 将标题和日志记录元素添加到页面中
    logDiv.appendChild(titleElement);
    document.body.appendChild(logDiv);

    function logAction(message) {
        var logItem = document.createElement('p');
        var timestamp = new Date().toLocaleTimeString();
        logItem.innerText = "[" + timestamp + "] " + message;
        logDiv.appendChild(logItem);
    }

    window.addEventListener('load', function() {
        var enterButton = document.getElementById('userCenterUrl');
        if (enterButton) {
            enterButton.click();
        }
    });


    function clickCalendar() {
        // 点击教学日历
        var linkElements = document.getElementsByClassName("tabs-link");
        for (var i = 0; i < linkElements.length; i++) {
            var linkElement = linkElements[i];
            if (linkElement.innerText === "教学日历") {
                linkElement.click();
                logAction("已点击教学日历按钮");
                break;
            }
        }

        // 点击进入课堂按钮后更新日志记录内容
        function clickEnterClassroom() {
            var btnElements = document.getElementsByClassName("btn-hollow-danger");
            for (var i = 0; i < btnElements.length; i++) {
                var btnElement = btnElements[i];
                if (btnElement.getAttribute("onclick").includes("openStuClassroom")) {
                    btnElement.click();
                    logAction("已点击进入课堂按钮");
                }
            }
        }

        // 在页面加载完成后执行操作
        window.addEventListener('load', function() {
            setTimeout(clickEnterClassroom, 2000); // 延迟2秒后执行点击进入课堂按钮
        });
    }

    function clickCheckinButton() {
        // 查找签到按钮
        var checkinButton = document.querySelector('div.participate-in');
        if (checkinButton && checkinButton.innerText === '签到') {
            // 点击签到按钮
            checkinButton.click();
            logAction("已点击签到按钮");
        } else {
            logAction("未找到签到按钮");
        }
    }

    if (window.location.href.match(/^https:\/\/spoc-classroom\.icve\.com\.cn\/.*$/)) {
        // 延迟10秒后关闭当前页面
        setTimeout(function() {
            window.close();
        }, 10000);
    }

    // 调用clickCalendar和clickCheckinButton函数
    clickCalendar();

    // 延迟5秒后执行自动化点击签到按钮的操作
    setTimeout(clickCheckinButton, 5000);

    setInterval(function() {
        location.reload(true); // 使用location.reload(true)来强制刷新页面
    }, 60000); // 每60秒刷新一次
})();
本文作者:任尚仁
版权声明:本文为原创内容,转载请注明出处。如需获取更多相关资讯,可访问官网:https://blog.rensr.site/。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇