// ==UserScript== // @name weiyong222 // @namespace http://tampermonkey.net/ // @version 2025-04-18 // @description 自动弹窗消除版客户跟进系统 // @author You // @match http://call.changmujiayu.cn/web/2024/* // @match https://call.changmujiayu.cn/web/2024/* // @grant none // ==/UserScript== (function() { 'use strict'; //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 自动关闭提示系统 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ const Toast = { show(msg, type = 'info') { const toast = document.createElement('div'); toast.textContent = msg; toast.style.cssText = ` position: fixed; top: 20px; right: 20px; padding: 12px 24px; background: ${type === 'error' ? '#ff4444' : '#4CAF50'}; color: white; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.2); z-index: 99999; opacity: 0; transform: translateY(-20px); transition: all 0.3s ease; `; document.body.appendChild(toast); setTimeout(() => { toast.style.opacity = '1'; toast.style.transform = 'translateY(0)'; }, 10); setTimeout(() => { toast.style.opacity = '0'; setTimeout(() => toast.remove(), 300); }, 3000); } }; //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 日期自动设置模块 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ const DateAutoSetter = { init() { this.retries = 0; this.observer = new MutationObserver(this.check.bind(this)); this.start(); }, start() { if(document.readyState === 'complete') { this.check(); } else { window.addEventListener('load', () => this.check()); document.addEventListener('DOMContentLoaded', () => this.check()); } this.observer.observe(document.body, { childList: true, subtree: true }); }, check() { const date1 = document.getElementById('date1'); const date2 = document.getElementById('date2'); if(date1 && date2) { this.setDates(date1, date2); this.triggerSearch(); this.observer.disconnect(); } else if(this.retries++ < 15) { setTimeout(() => this.check(), 300); } }, setDates(date1, date2) { const today = new Date(); const pad = n => String(n).padStart(2,'0'); const dateStr = `${today.getFullYear()}-${pad(today.getMonth()+1)}-${pad(today.getDate())}`; [date1, date2].forEach(el => { el.value = dateStr; ['input', 'change', 'blur'].forEach(event => { el.dispatchEvent(new Event(event, { bubbles: true })); }); }); }, triggerSearch() { setTimeout(() => { if(typeof load_search_info === 'function') { load_search_info(); console.log('自动筛选已执行'); } }, 800); } }; //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 控制面板创建 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ function createControlPanel() { if (!document.getElementById("refreshDelay")) { const form = document.createElement("form"); form.style.cssText = ` position: fixed; right: 20px; top: 80px; z-index: 9998; background: #fff; padding: 15px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); `; // 刷新间隔输入 const input = document.createElement("input"); input.type = "number"; input.id = "refreshDelay"; input.placeholder = "刷新间隔(ms)"; input.value = 30; input.style.cssText = ` width: 120px; padding: 6px; margin-bottom: 10px; display: block; `; // 时间单位选择 const unitContainer = document.createElement("div"); unitContainer.style.marginBottom = "10px"; const createRadio = (value, label, checked) => { const container = document.createElement("div"); container.style.display = "inline-block"; container.style.marginRight = "15px"; const radio = document.createElement("input"); radio.type = "radio"; radio.name = "unit"; radio.value = value; radio.id = value; radio.checked = checked; const labelEl = document.createElement("label"); labelEl.htmlFor = value; labelEl.textContent = label; labelEl.style.marginLeft = "5px"; container.append(radio, labelEl); return container; }; // 操作按钮 const button = document.createElement("button"); button.type = "button"; button.id = "runButton"; button.textContent = "启动"; button.style.cssText = ` padding: 8px 16px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; transition: background 0.3s; `; button.onmouseover = () => button.style.background = '#45a049'; button.onmouseout = () => button.style.background = '#4CAF50'; // 组装组件 unitContainer.append( createRadio("minute", "分", true), createRadio("second", "秒", false) ); form.append(input, unitContainer, button); document.body.appendChild(form); // 事件绑定 button.onclick = function() { const wait = input.value; if (!wait || isNaN(wait)) { Toast.show("请输入有效数字", 'error'); return; } if(window.timerSearchInfo) { clearInterval(window.timerSearchInfo); window.timerSearchInfo = null; Toast.show("已停止自动刷新"); this.textContent = "启动"; } else { this.textContent = "停止"; window.timerSearchInfo = setInterval(() => { load_search_info(); console.log("自动刷新执行"); }, parseInt(wait)); } }; } } //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 业务逻辑函数 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ function load_search_info() { o["tel"] = document.getElementById("phone2").value; o["channel"] = document.getElementById("pkey_id").value; o["mer_id"] = document.getElementById("mer_id").value; o["dat1"] = document.getElementById("date1").value; o["dat2"] = document.getElementById("date2").value; o["hasName"] = document.getElementById("hasName").value; o["page"] = 1; o["user_type"] = 1; $.ajax({ type: "POST", url: "api/high_seas_list.php?ak=" + getQueryString('ak'), data: dess(o), success: function(data0) { const data = desj(data0); data.arr.forEach(item => { if(time_diff(item.reg_tim, document.getElementById("minute").checked)) { console.log("发现新客户:", item.tel); follow_info(item.tel, item.id); } }); }, error: () => Toast.show("数据加载失败", 'error') }); } function follow_info(tel, id) { $.ajax({ type: "GET", url: `api/begin_one.php?tel=${tel}&id=${id}&ak=${getQueryString("ak")}`, success: function(data) { o = data; if (o.status) { $(`.status_${tel}`).html("跟进中"); $(`.caller_${tel}`).html(o.nickname); $(`.tel1_${tel}`) .after(`反馈跟进结果`) .remove(); } Toast.show(o.message, o.status ? 'info' : 'error'); if (o.status === 1) { window.location = `private_list.php?ak=${getQueryString('ak')}`; } }, error: () => Toast.show("跟进请求失败", 'error') }); } function time_diff(s, use_minute) { if (!s) return false; try { const [datePart, timePart] = s.split(' '); const [year, month, day] = datePart.split('-').map(Number); const [hours, minutes, seconds] = timePart.split(':').map(Number); const timer = new Date(year, month-1, day, hours, minutes, seconds); const now = new Date(); return use_minute ? timer.toLocaleDateString() === now.toLocaleDateString() && timer.getHours() === now.getHours() && timer.getMinutes() === now.getMinutes() : timer.getTime() - now.getTime() < 60000; } catch(e) { console.error("时间解析错误:", e); return false; } } //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 初始化 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ DateAutoSetter.init(); setTimeout(createControlPanel, 500); // 延迟确保DOM加载完成 })();