BOSS直接自动点击未读消息并发送求简历请求
最新版本代码 26-04-23 修复没有对话无法发送求简历按钮
(() => { /****************************************************************** * 可配置参数 ******************************************************************/ const CONFIG = { countdownSeconds: 3, openConfirmDelayMs: 300, requestResultTimeoutMs: 5000, switchConversationDelayMs: 1000, listScrollStep: 700, pollIntervalMs: 200, uniqueNames: false, maxShowNames: 300, enablePeriodicRefresh: true, refreshEveryConversationCount: 40, refreshTabKeyword: "新招呼", refreshAfterClickDelayMs: 800, // 灰色“求简历”但未请求时,直接模拟输入的文案 manualUnlockMessageText: "可以发一份简历看看吗", // 模拟发送后,先等 1 秒 manualUnlockWaitAfterSendMs: 1000, // 发送后等待“求简历”解锁的最长时间 manualUnlockTimeoutMs: 5000, sameNameLoopLimit: 2 }; /****************************************************************** * 如果旧脚本存在,先停掉 ******************************************************************/ if (window.__bossResumeBot && typeof window.__bossResumeBot.stop === "function") { try { window.__bossResumeBot.stop(); } catch (e) {} } /****************************************************************** * 全局状态 ******************************************************************/ const state = { running: true, paused: false, stopRequested: false, requestedCount: 0, requestedRecords: [], countdown: 0, status: "初始化中...", phase: "idle", currentName: "", panel: null, processedConversationCount: 0, lastRefreshAtProcessedCount: 0, lastSwitchedName: "", sameNameHitCount: 0 }; class StopError extends Error { constructor(message = "脚本已停止") { super(message); this.name = "StopError"; } } /****************************************************************** * 基础工具函数 ******************************************************************/ function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } function textOf(el) { return (el?.textContent || "").replace(/\s+/g, " ").trim(); } function normalizeText(str) { return String(str ?? "").replace(/\s+/g, " ").trim(); } function qs(selector, root = document) { return root.querySelector(selector); } function qsa(selector, root = document) { return [...root.querySelectorAll(selector)]; } function visible(el) { if (!el) return false; const style = getComputedStyle(el); const rect = el.getBoundingClientRect(); return ( style.display !== "none" && style.visibility !== "hidden" && rect.width > 0 && rect.height > 0 ); } function click(el) { if (!el) return false; el.dispatchEvent( new MouseEvent("click", { bubbles: true, cancelable: true, view: window }) ); return true; } function escapeHtml(str) { return String(str ?? "") .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .replaceAll('"', """) .replaceAll("'", "'"); } function excelCell(str) { return escapeHtml(String(str ?? "")).replace(/\n/g, "<br>"); } function nowString() { const d = new Date(); const y = d.getFullYear(); const m = String(d.getMonth() + 1).padStart(2, "0"); const day = String(d.getDate()).padStart(2, "0"); const h = String(d.getHours()).padStart(2, "0"); const min = String(d.getMinutes()).padStart(2, "0"); const s = String(d.getSeconds()).padStart(2, "0"); return `${y}-${m}-${day} ${h}:${min}:${s}`; } function pickFirst(arr = [], matcher) { return arr.find(item => matcher(item)) || ""; } /****************************************************************** * 运行控制 ******************************************************************/ function guardRunning() { if (!state.running || state.stopRequested) { throw new StopError(); } } async function interruptibleSleep(ms) { let elapsed = 0; while (elapsed < ms) { guardRunning(); while (state.paused) { state.phase = "paused"; renderPanel(); await sleep(CONFIG.pollIntervalMs); guardRunning(); } const step = Math.min(CONFIG.pollIntervalMs, ms - elapsed); await sleep(step); elapsed += step; } } function pauseRunner() { if (!state.running) return; state.paused = true; state.phase = "paused"; state.status = "已暂停"; renderPanel(); } function resumeRunner() { if (!state.running) return; state.paused = false; state.phase = "idle"; state.status = "继续运行中..."; renderPanel(); } function stopRunner() { state.stopRequested = true; state.running = false; state.paused = false; state.countdown = 0; state.phase = "stopped"; state.status = "已停止"; renderPanel(); } /****************************************************************** * 面板 ******************************************************************/ function createPanel() { const old = document.getElementById("__boss_resume_panel"); if (old) old.remove(); const panel = document.createElement("div"); panel.id = "__boss_resume_panel"; panel.style.cssText = ` position: fixed; top: 16px; right: 16px; z-index: 999999; width: 390px; max-height: 82vh; overflow: hidden; background: rgba(15, 23, 42, 0.95); color: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.28); font: 14px/1.6 Arial, sans-serif; user-select: text; border: 1px solid rgba(255,255,255,0.1); `; panel.addEventListener("click", (e) => { const act = e.target?.dataset?.act; if (!act) return; if (act === "pause") pauseRunner(); if (act === "resume") resumeRunner(); if (act === "stop") stopRunner(); if (act === "export") exportRequestedToExcel(); }); document.body.appendChild(panel); return panel; } function renderPanel() { if (!state.panel) return; const list = state.requestedRecords.slice(0, CONFIG.maxShowNames); const listHtml = list.length ? list.map(item => ` <div style="padding:4px 0; border-bottom:1px dashed rgba(255,255,255,.08);"> ${escapeHtml(item.name || "未识别姓名")} </div> `).join("") : `<div style="opacity:.7;">暂无</div>`; state.panel.innerHTML = ` <div style="padding:12px 14px; border-bottom:1px solid rgba(255,255,255,.08);"> <div style="font-size:16px; font-weight:700;">求简历助手</div> <div style="font-size:12px; opacity:.75;">支持暂停 / 继续 / 停止 / 导出Excel</div> </div> <div style="padding:12px 14px;"> <div><b>已请求 ${state.requestedCount} 次</b></div> <div>已处理会话 ${state.processedConversationCount} 个</div> <div>倒计时 ${state.countdown}</div> <div>当前阶段:${escapeHtml(state.phase)}</div> <div>当前状态:${escapeHtml(state.status)}</div> <div>当前姓名:${escapeHtml(state.currentName || "未识别")}</div> <div>当前倒计时参数:${CONFIG.countdownSeconds} 秒</div> <div>每 ${CONFIG.refreshEveryConversationCount} 个会话刷新一次新消息</div> <div style="margin-top:10px; display:flex; gap:8px; flex-wrap:wrap;"> <button>// 点击第一个“有未读数字”的会话 const target = [...document.querySelectorAll('.geek-item')].find(item => { const countText = item.querySelector('.badge-count span')?.textContent?.trim(); return Number(countText) > 0; }); if (target) { target.click(); }2、找到可以发送收简历的窗口,收简历
3、循环读取最后一份简历,并且点击 求简历按钮
【说明】
这是点击未读消息后出现的我两种简历3种对话框以及对应的html,我想实现 当如果没有请求过简历点击求简历按钮,等待10秒钟自动切换写一个 求简历如此反复,并且在屏幕上显示已发送多少次请求,显示 已请求 8次 倒计时 10 已请求 8次 倒计时 9 已请求 8次 倒计时 8 。。。 直到切换下一页,还有倒计时时间作为参数放在顶部可以修改,并且能够暂停 停止当前操作,把已请求姓名都列出来一行一个,增加一个按钮把已请求简历的名单能够导出excel。
(() => { /****************************************************************** * 可配置参数 ******************************************************************/ const CONFIG = { // 每个会话处理完成后,倒计时多少秒再切换到下一条 countdownSeconds: 10, // 点击“求简历”后,等待确认弹层出现的时间 openConfirmDelayMs: 300, // 点击“确定”后,最多等待多久确认“简历请求已发送” requestResultTimeoutMs: 5000, // 切换到下一条会话后,等待页面渲染时间 switchConversationDelayMs: 1000, // 左侧列表找不到下一条时,向下滚动的距离 listScrollStep: 700, // 内部轮询间隔 pollIntervalMs: 200, // 名单中是否去重 // true 同一个名字只保留一条 // false 同一个名字请求几次就记几条 uniqueNames: false, // 面板中最多展示多少条已请求姓名 maxShowNames: 300 }; /****************************************************************** * 如果旧脚本存在,先停掉,防止重复运行 ******************************************************************/ if (window.__bossResumeBot && typeof window.__bossResumeBot.stop === "function") { try { window.__bossResumeBot.stop(); } catch (e) {} } /****************************************************************** * 全局状态 ******************************************************************/ const state = { running: true, paused: false, stopRequested: false, requestedCount: 0, requestedRecords: [], countdown: 0, status: "初始化中...", phase: "idle", currentName: "", panel: null }; /****************************************************************** * 自定义停止异常 ******************************************************************/ class StopError extends Error { constructor(message = "脚本已停止") { super(message); this.name = "StopError"; } } /****************************************************************** * 基础工具函数 ******************************************************************/ function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } function textOf(el) { return (el?.textContent || "").replace(/\s+/g, " ").trim(); } function qs(selector, root = document) { return root.querySelector(selector); } function qsa(selector, root = document) { return [...root.querySelectorAll(selector)]; } function visible(el) { if (!el) return false; const style = getComputedStyle(el); const rect = el.getBoundingClientRect(); return ( style.display !== "none" && style.visibility !== "hidden" && rect.width > 0 && rect.height > 0 ); } function click(el) { if (!el) return false; el.dispatchEvent( new MouseEvent("click", { bubbles: true, cancelable: true, view: window }) ); return true; } function escapeHtml(str) { return String(str ?? "") .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .replaceAll('"', """) .replaceAll("'", "'"); } function excelCell(str) { return escapeHtml(String(str ?? "")).replace(/\n/g, "<br>"); } function nowString() { const d = new Date(); const y = d.getFullYear(); const m = String(d.getMonth() + 1).padStart(2, "0"); const day = String(d.getDate()).padStart(2, "0"); const h = String(d.getHours()).padStart(2, "0"); const min = String(d.getMinutes()).padStart(2, "0"); const s = String(d.getSeconds()).padStart(2, "0"); return `${y}-${m}-${day} ${h}:${min}:${s}`; } function normalizeText(str) { return String(str ?? "").replace(/\s+/g, " ").trim(); } function pickFirst(arr = [], matcher) { return arr.find(item => matcher(item)) || ""; } /****************************************************************** * 运行控制 ******************************************************************/ function guardRunning() { if (!state.running || state.stopRequested) { throw new StopError(); } } async function interruptibleSleep(ms) { let elapsed = 0; while (elapsed < ms) { guardRunning(); while (state.paused) { state.phase = "paused"; renderPanel(); await sleep(CONFIG.pollIntervalMs); guardRunning(); } const step = Math.min(CONFIG.pollIntervalMs, ms - elapsed); await sleep(step); elapsed += step; } } function pauseRunner() { if (!state.running) return; state.paused = true; state.phase = "paused"; state.status = "已暂停"; renderPanel(); } function resumeRunner() { if (!state.running) return; state.paused = false; state.phase = "idle"; state.status = "继续运行中..."; renderPanel(); } function stopRunner() { state.stopRequested = true; state.running = false; state.paused = false; state.countdown = 0; state.phase = "stopped"; state.status = "已停止"; renderPanel(); } /****************************************************************** * 浮动面板 ******************************************************************/ function createPanel() { const old = document.getElementById("__boss_resume_panel"); if (old) old.remove(); const panel = document.createElement("div"); panel.id = "__boss_resume_panel"; panel.style.cssText = ` position: fixed; top: 16px; right: 16px; z-index: 999999; width: 380px; max-height: 82vh; overflow: hidden; background: rgba(15, 23, 42, 0.95); color: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.28); font: 14px/1.6 Arial, sans-serif; user-select: text; border: 1px solid rgba(255,255,255,0.1); `; panel.addEventListener("click", (e) => { const act = e.target?.dataset?.act; if (!act) return; if (act === "pause") pauseRunner(); if (act === "resume") resumeRunner(); if (act === "stop") stopRunner(); if (act === "export") exportRequestedToExcel(); }); document.body.appendChild(panel); return panel; } function renderPanel() { if (!state.panel) return; const list = state.requestedRecords.slice(0, CONFIG.maxShowNames); const listHtml = list.length ? list.map(item => ` <div style="padding:4px 0; border-bottom:1px dashed rgba(255,255,255,.08);"> ${escapeHtml(item.name || "未识别姓名")} </div> `).join("") : `<div style="opacity:.7;">暂无</div>`; state.panel.innerHTML = ` <div style="padding:12px 14px; border-bottom:1px solid rgba(255,255,255,.08);"> <div style="font-size:16px; font-weight:700;">求简历助手</div> <div style="font-size:12px; opacity:.75;">支持暂停 / 继续 / 停止 / 导出Excel</div> </div> <div style="padding:12px 14px;"> <div><b>已请求 ${state.requestedCount} 次</b></div> <div>倒计时 ${state.countdown}</div> <div>当前阶段:${escapeHtml(state.phase)}</div> <div>当前状态:${escapeHtml(state.status)}</div> <div>当前姓名:${escapeHtml(state.currentName || "未识别")}</div> <div>当前倒计时参数:${CONFIG.countdownSeconds} 秒</div> <div style="margin-top:10px; display:flex; gap:8px; flex-wrap:wrap;"> <button>document.querySelectorAll('.geek-item').forEach(item => { const countText = item.querySelector('.badge-count span')?.textContent?.trim(); if (Number(countText) > 0) { item.click(); } });