Greasy Fork

Greasy Fork is available in English.

一键沟通boss

沟通

目前为 2024-02-23 提交的版本,查看 最新版本

    // ==UserScript==
// @name         一键沟通boss
// @license      GPL-3.0
// @namespace    http://tampermonkey.net/
// @version      2024-02-22
// @description  沟通
// @author       You
// @match        https://www.zhipin.com/*
// @icon         https://static.zhipin.com/v2/web/geek/images/logo.png
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    // 定义一个等待函数
    function wait(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }
    function getRandomInteger(min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }
    // 创建一个容器
    let container = document.createElement('div');
    container.style.position = 'fixed';
    container.style.top = '50px';
    container.style.right = '10px';
    container.style.zIndex = '10000';
    document.body.appendChild(container);


    // 创建一键沟通按钮
    let communicateBtn = document.createElement('button');
    communicateBtn.textContent = '一键沟通';
    container.appendChild(communicateBtn);



    communicateBtn.addEventListener('click', function() {
        // 获取所有具有 "start-chat-btn" 类的元素
        var buttons = document.getElementsByClassName("start-chat-btn");

        // 定义一个函数,用于执行延迟点击
        async function delayedClick(index) {
            if (index >= buttons.length) {
                console.log("所有按钮点击完成");
                 alert('执行完毕');
                return; // 如果所有按钮都已经被点击,就退出函数
            }
            if( buttons[index].innerText==="继续沟通"){

            }else{
                // 触发点击
                buttons[index].click();
                console.log("按钮 " + index + " 被点击");
                await wait(2000)
                document.querySelector("body > div.greet-boss-dialog > div.greet-boss-container > div.greet-boss-footer > a.default-btn.cancel-btn").click()
            }

            await wait(getRandomInteger(300, 2000))
            // 设置下一个点击的延迟
            setTimeout(function() {
                delayedClick(index + 1);
            }, 1000); // 这里设置的延迟是1000毫秒(1秒)
        }

        // 开始遍历并延迟点击每个按钮
        delayedClick(0);


    });



})();