【油猴脚本】健康打卡自动化

健康打卡自动化

填写体温,勾选选项,提交,关闭一气呵成~
如果想定时,可以添加打卡网页到启动浏览器打开特定网页,然后添加定时任务打开浏览器。
【油猴脚本】健康打卡自动化_第1张图片

脚本地址:https://greasyfork.org/zh-CN/scripts/404938-stu-dailyreport-automator

借鉴东南大学打卡自动化脚本:https://greasyfork.org/zh-CN/scripts/398138-seu-lwreportepidemicseu-dailyreport-automator

源码

// ==UserScript==
// @name         STU dailyReport Automator
// @name:zh      健康打卡自动化
// @name:zh-CN   健康打卡自动化
// @namespace    http://my.stu.edu.cn/
// @version      0.01
// @license      Anti 996 License
// @description  Automatically completes the health daily report during the Wuhan pneumonia pandemic.
// @description:zh 自动完成汕头大学线上服务健康打卡过程。
// @description:zh-CN 自动完成汕头大学线上服务健康打卡过程。借鉴@SaltfishAmi东南大学健康打卡自动化脚本https://greasyfork.org/zh-CN/scripts/398138-seu-lwreportepidemicseu-dailyreport-automator
// @author       yunjingshan
// @include      https://my.stu.edu.cn/health-report/login.html?_t=1591603871484
// @include      https://my.stu.edu.cn/health-report/report/report.do
// @include      https://sso.stu.edu.cn/login?service=https%3A%2F%2Fmy.stu.edu.cn%2Fhealth-report%2Finit-stu-user
// @grant        none
// ==/UserScript==

//======================CONFIG======================
// Credentials for auto-login
    var username = "username";
    var password = "password";
// Timeout settings in ms
    var timeoutBeforeLogin = 1500;
    var timeoutBeforeClickSummit = 2000;
    var timeoutBeforeCloseWindows = 3000;

//Temperature setting
    //var temperature = String((361 + Math.floor(Math.random() * 10))/10.0);
    var temperature = String(36.4);//固定温度
//==================================================

    function $(id){
        return document.getElementById(id);
    }
    function $$(classname){
        return document.getElementsByClassName(classname);
    }
    function $$$(name){
        return document.getElementsByName(name);
    }
    var clickevt = document.createEvent("MouseEvents");
    clickevt.initEvent("click", true, true);

(function() {
    'use strict';

    if(username=="username"){
        // username check
        alert("Please edit the script and set your username & password! \n请编辑脚本,指定你的用户名和密码!");
        alert("The script will now terminate. \n脚本执行中断。");
        return false;
    }

    if(window.location.hostname != "my.stu.edu.cn"){
        // login
        $("username").value = username;
        $("password").value = password;

        setTimeout(function(){
            $$("login-button")[0].dispatchEvent(clickevt);
        }, timeoutBeforeLogin);

    } else {

        setTimeout(function(){

            //填写体温
            $$$("dailyReport.afternoorBodyHeat")[0].value = temperature;
            $$$("dailyReport.forenoonBodyHeat")[0].value = temperature;
            //window.alert($$$("dailyReport.forenoonBodyHeat")[0].value);

            //勾选
            $$$("dailyReport.hasCough")[1].checked="Ture";
            $$$("dailyReport.hasShortBreath")[1].checked="Ture";
            $$$("dailyReport.hasWeak")[1].checked="Ture";
            $$$("dailyReport.hasFever")[1].checked="Ture";
            //window.alert($$$("dailyReport.hasCough")[1].checked);

            //提交健康信息按钮
            $("submitBtn3").click();
            //window.alert($("submitBtn3"));

        }, timeoutBeforeClickSummit);

        setTimeout(function(){
            //window.alert($("noticeMsg").innerHTML);
            if(/数据已上报成功/.test($("noticeMsg").innerHTML)){
                //window.alert("提交成功");
                window.close();
            };
        }, timeoutBeforeCloseWindows);
    }
})();

版本2

  • 增加防止多次提交功能
// ==UserScript==
// @name         STU dailyReport Automator
// @name:zh      汕头大学健康打卡自动化
// @name:zh-CN   汕头大学健康打卡自动化
// @namespace    http://my.stu.edu.cn/
// @version      0.01
// @license      Anti 996 License
// @description  Automatically completes the health daily report during the Wuhan pneumonia pandemic.
// @description:zh 自动完成汕头大学线上服务健康打卡过程。
// @description:zh-CN 自动完成汕头大学线上服务健康打卡过程。借鉴@SaltfishAmi东南大学健康打卡自动化脚本https://greasyfork.org/zh-CN/scripts/398138-seu-lwreportepidemicseu-dailyreport-automator
// @author       yunjingshan
// @include      https://my.stu.edu.cn/health-report/login.html?_t=1591603871484
// @include      https://my.stu.edu.cn/health-report/report/report.do
// @include      https://sso.stu.edu.cn/login?service=https%3A%2F%2Fmy.stu.edu.cn%2Fhealth-report%2Finit-stu-user
// @grant        none
// ==/UserScript==

//======================CONFIG======================
// Credentials for auto-login
    var username = "16sswu";
    var password = "Xsw234";
// Timeout settings in ms
    var timeoutBeforeLogin = 1500;
    var timeoutBeforeClickSummit = 2000;
    var timeoutBeforeCloseWindows = 3000;

//Temperature setting
    var temperature = String((363 + Math.floor(Math.random() * 5))/10.0);
    var temperature2 = String((363 + Math.floor(Math.random() * 5))/10.0);
    //var temperature = String(36.4);//固定温度
//==================================================

    function $(id){
        return document.getElementById(id);
    }
    function $$(classname){
        return document.getElementsByClassName(classname);
    }
    function $$$(name){
        return document.getElementsByName(name);
    }
    function WriteandSumm(){
        setTimeout(function(){

            //填写体温
            $$$("dailyReport.afternoorBodyHeat")[0].value = temperature;
            $$$("dailyReport.forenoonBodyHeat")[0].value = temperature2;
            //window.alert($$$("dailyReport.forenoonBodyHeat")[0].value);

            //勾选
            $$$("dailyReport.hasCough")[1].checked="Ture";
            $$$("dailyReport.hasShortBreath")[1].checked="Ture";
            $$$("dailyReport.hasWeak")[1].checked="Ture";
            $$$("dailyReport.hasFever")[1].checked="Ture";
            //window.alert($$$("dailyReport.hasCough")[1].checked);

            //提交健康信息按钮
            $("submitBtn3").click();
            //window.alert($("submitBtn3"));

        }, timeoutBeforeClickSummit);

        setTimeout(function(){
            //window.alert($("noticeMsg").innerHTML);
            if(/数据已上报成功/.test($("noticeMsg").innerHTML)){
                window.alert("提交成功");
                //window.close();
            };
        }, timeoutBeforeCloseWindows);
    }
    var clickevt = document.createEvent("MouseEvents");
    clickevt.initEvent("click", true, true);


(function() {
    'use strict';
    //$$("welcome")[0].style.backgroundColor = "red";
    //window.alert($$("welcome")[0].innerText);

    if(username=="username"){
        // username check
        alert("Please edit the script and set your username & password! \n请编辑脚本,指定你的用户名和密码!");
        alert("The script will now terminate. \n脚本执行中断。");
        return false;
    }

    if(window.location.hostname != "my.stu.edu.cn"){
        // login
        $("username").value = username;
        $("password").value = password;

        setTimeout(function(){
            $$("login-button")[0].dispatchEvent(clickevt);
        }, timeoutBeforeLogin);

    } else {

        if($$("welcome")[0].innerText.indexOf("今天已填报")!=-1){
            window.alert($$("welcome")[0].innerText);
        }
        else{
         WriteandSumm();
        }
     }
})();


你可能感兴趣的:(脚本)