Auto punch in and out

try to take over the world!

// ==UserScript==
// @name         Auto punch in and out
// @namespace    http://tampermonkey.net/
// @version      1.1.14
// @description  try to take over the world!
// @author       You
// @match        *://timestar.insperity.com/*/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=insperity.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const KEEP_CHECKING_TIME=240000;//每隔多少分钟去点击一下按钮并且检测是否够8:00
    const CHECK_LOGIN_TIME=1000;//检测登陆与否的间隔时间
    const CLOCK_IN_TIME="8:0";


    let inDay=CLOCK_IN_TIME,
        inLunch="",
        outLunch="",
        outDay="";

    let autoClock=true;
    let inClockDay=""; // 今日是否打卡了,如果今天已经打卡,这里存储的是今天的日期


    let i=1;
    let base = setInterval(function(){

        console.log("尝试次数"+ ++i)
        if($(".header_punch_link").length>0){


                $(".timestar_heading_top_content_wrap").append(`<div style="margin-left:300px">
   <font style="color:red;font-weight: bold;">I_D </font><input size=5 id="In_For_Day" class="timeSet" value="${inDay}"/>
   <font style="color:red;font-weight: bold;">O_L </font><input size=5 id="Out_For_Lunch" class="timeSet" value="${outLunch}"/>
   <font style="color:red;font-weight: bold;">I_L </font><input size=5 id="In_From_Lunch" class="timeSet"" value="${inLunch}"/>
   <font style="color:red;font-weight: bold;">O_D </font><input size=5 id="Out" class="timeSet" value="${outDay}"/>
   <br><button id="setTime" style="width:50px">Set</button><span id="set_in_what_time" style="color:red;margin-left:30px"></span>
   <button id="resetTime" style="width:50px">Clear</button><button id="autoCheck" style="background:green">Auto Clock : ON</button>
</div>
    `)

            $("#resetTime").on("click",function(){
                $(".timeSet").val("")
            });

            $("#setTime").on("click",function(){
                inDay=$("#In_For_Day").val();
                inLunch=$("#In_From_Lunch").val();
                outLunch=$("#Out_For_Lunch").val();
                outDay=$("#Out").val();
                $("#set_in_what_time").text((new Date().getMonth()+1)+'-'+(new Date().getDate())+" "+(new Date().getHours())+":"+(new Date().getMinutes()));
                console.log(inDay,inLunch,outLunch,outDay)
            })

            $("#autoCheck").click(function(){
                autoClock=!autoClock;
                if(autoClock){//如果是off;
                    $(this).text("Auto Clock : ON")
                    $(this).css("background","green")
                }else{//如果是false
                    $(this).text("Auto Clock : OFF")
                    $(this).css("background","red")
                }
            })

            clearInterval(base);

            setInterval(function(){//负责控制seccion不过期,并且侦测日期是否今天
                let nowTime=new Date().getHours()+":"+new Date().getMinutes();
                console.log(nowTime);
                $(".header_link.timestar_link").text("更新时间---"+nowTime+":"+new Date().getSeconds())
                if(nowTime!=CLOCK_IN_TIME){
                    $(".company_logo_link").click()
                    // ui-icon-closethick
                }

                //侦测今日日期是否已经打卡
                let todayDate
                if(todayDate!=inClockDay){
                    inClockDay=todayDate;
                    $("#In_For_Day").val(CLOCK_IN_TIME)
                    inDay=CLOCK_IN_TIME;
                }
            }, KEEP_CHECKING_TIME);
        }
    },CHECK_LOGIN_TIME);

    setInterval(function(){//打卡侦测
        if(autoClock){
            let nowTime=new Date().getHours()+":"+new Date().getMinutes();
            console.log(inDay,inLunch,outLunch,outDay)
            $(".clock_punch_category_btn").each(function(){// in for day
                if(this.innerText=="IN FOR DAY" && nowTime==inDay){// in for day
                    $(this).click();
                    //$(this).text(inDay)
                    inDay="";
                    $("#In_For_Day").val("");
                }if(this.innerText=="IN FROM LUNCH" && nowTime==inLunch){// in from Lunch
                    $(this).click();
                    //$(this).text(inLunch);
                    inLunch="";
                    $("#In_From_Lunch").val("");
                }if(this.innerText=="OUT" && nowTime==outDay){// out for day
                    $(this).click();
                    //$(this).text(outDay);
                    outDay=""
                    $("#Out").val("");
                }if(this.innerText=="OUT FOR LUNCH" && nowTime==outLunch){// out for lunch
                    $(this).click();
                    //$(this).text(outLunch)
                    outLunch="";
                    $("#Out_For_Lunch").val("");
                }else{
                    console.log(nowTime+":"+new Date().getSeconds())
                }
            })
        }

    },60000)

    setInterval(function(){//侦测打卡界面是否显示
console.log(new Date())
        if(autoClock && $(".clock_punch_category_btn ").length==0){
            $(".header_punch_link").click()
        }
    },30000)

    // Your code here...
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址