微步下班倒计时

try to take over the world!

目前為 2023-08-13 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         微步下班倒计时
// @namespace    http://tampermonkey.net/
// @version      2023年8月13日19点57分
// @description  try to take over the world!
// @author       wwsuixin
// @match        https://x.threatbook.com/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=threatbook.com
// @grant        none
// ==/UserScript==

(function () {

    window.onload = setTimeout(click_item, 500);
    function click_item() {
        var xpath = '//*[@id="app"]/div[1]/div[1]/div[2]/div[6]/div[2]';
        var element = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        var newData = document.createElement('div');
        // 给这个div添加css
        newData.style.color = "red";
        newData.style.fontSize = "16px";
        newData.style.fontWeight = "bold";
        newData.style.fontFamily = "楷体";


        if (element) {

            // 执行上面的代码
            var 下班时间 = new Date();
            下班时间.setHours(22, 0, 0, 0);
            var 上班时间 = new Date();
            上班时间.setHours(8, 30, 0, 0);
            setInterval(function () {
                let 当前时间 = new Date();
                let 距离上班时间间隔 = 当前时间 - 上班时间;
                let 距离下班时间间隔 = 下班时间 - 当前时间;
                var 提示信息 = "";
                var 下班提示信息 = "";
                var 上班提示信息 = "";
                if (距离下班时间间隔 < 0) {
                    下班提示信息 = "警告:工作时间已经结束!"
                } else {
                    let days = Math.floor(距离下班时间间隔 / (1000 * 60 * 60 * 24));
                    let hours = Math.floor((距离下班时间间隔 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                    let minutes = Math.floor((距离下班时间间隔 % (1000 * 60 * 60)) / (1000 * 60));
                    let seconds = Math.floor((距离下班时间间隔 % (1000 * 60)) / 1000);
                    下班提示信息 = "🕙 距离下班:" + hours + "小时 " + minutes + "分钟 " + seconds + "秒"
                }

                let days = Math.floor(距离上班时间间隔 / (1000 * 60 * 60 * 24));
                let hours = Math.floor((距离上班时间间隔 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                let minutes = Math.floor((距离上班时间间隔 % (1000 * 60 * 60)) / (1000 * 60));
                let seconds = Math.floor((距离上班时间间隔 % (1000 * 60)) / 1000);
                上班提示信息 = "🕢 已经工作:" + hours + "小时 " + minutes + "分钟 " + seconds + "秒";

                提示信息 = "<span>"+上班提示信息 +"</span><br /><span>"+ 下班提示信息+"</span>"

                newData.innerHTML = 提示信息;
                element.appendChild(newData);
                //console.log(提示信息)
            },1000);
        } else {
            setTimeout(click_item, 300) //300 毫秒
        }
    }
})();