// ==UserScript== // @name tc脚本 // @namespace http://tampermonkey.net/ // @version 20260616 // @description 自动跟进系统(带密码验证) // @author You // @match http://call.yunxttech.com/web/admin/page/erp_zk2/* // @match https://call.yunxttech.com/web/admin/page/erp_zk2/* // @grant none // ==/UserScript== (function() { 'use strict'; console.log('TC脚本开始执行...'); //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 密码验证配置 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ const VERIFY_PASSWORD = '889951'; const VERIFY_KEY = 'zk_script_verified'; const VERIFY_EXPIRY_DAYS = 300; // 检查是否已验证 function isVerified() { const verified = localStorage.getItem(VERIFY_KEY); if (!verified) return false; try { const data = JSON.parse(verified); const now = Date.now(); if (data.expiry && now > data.expiry) { localStorage.removeItem(VERIFY_KEY); return false; } return true; } catch (e) { return false; } } // 设置验证状态 function setVerified() { const data = { verified: true, expiry: Date.now() + (VERIFY_EXPIRY_DAYS * 24 * 60 * 60 * 1000) }; localStorage.setItem(VERIFY_KEY, JSON.stringify(data)); } // 密码验证界面 function showPasswordModal() { if (isVerified()) { console.log('已验证,直接执行主流程'); init(); return; } const overlay = document.createElement('div'); overlay.id = 'verify-overlay'; overlay.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); z-index: 999999; display: flex; justify-content: center; align-items: center; font-family: Arial, sans-serif; `; const modal = document.createElement('div'); modal.style.cssText = ` background: white; padding: 30px; border-radius: 10px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); text-align: center; max-width: 350px; width: 90%; `; modal.innerHTML = `

请输入访问密码

`; overlay.appendChild(modal); document.body.appendChild(overlay); const passwordInput = document.getElementById('verify-password'); const errorMsg = document.getElementById('verify-error'); const submitBtn = document.getElementById('verify-submit'); const cancelBtn = document.getElementById('verify-cancel'); setTimeout(() => passwordInput.focus(), 100); function verify() { const password = passwordInput.value.trim(); if (!password) { errorMsg.textContent = '请输入密码'; passwordInput.focus(); return; } if (password === VERIFY_PASSWORD) { setVerified(); overlay.remove(); console.log('密码验证成功'); Toast.show('验证成功,正在加载...', 'info'); init(); } else { errorMsg.textContent = '密码错误,请重试'; passwordInput.value = ''; passwordInput.focus(); modal.style.animation = 'shake 0.5s'; setTimeout(() => modal.style.animation = '', 500); } } submitBtn.onclick = verify; cancelBtn.onclick = function() { overlay.remove(); Toast.show('已取消访问', 'error'); }; passwordInput.onkeypress = function(e) { if (e.key === 'Enter') { verify(); } }; const style = document.createElement('style'); style.textContent = ` @keyframes shake { 0%, 100% { transform: translateX(0); } 10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); } 20%, 40%, 60%, 80% { transform: translateX(5px); } } `; document.head.appendChild(style); } //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 自动关闭提示系统 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ 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); } }; //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 拦截弹窗 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ (function() { console.log('设置弹窗拦截...'); window._originalAlert = window.alert; window._originalConfirm = window.confirm; window._originalPrompt = window.prompt; window.addEventListener('error', function(e) { if (e.filename && e.filename.includes('high_seas_list')) { console.log('忽略网页错误:', e.message); e.preventDefault(); } }); window.alert = function(msg) { console.log('拦截alert:', msg); if (msg && msg.includes('跟进失败')) { // 触发刷新 setTimeout(() => { const filterBtn = document.querySelector('.btn-primary.btn-block'); if (filterBtn && filterBtn.textContent.includes('筛选')) { filterBtn.click(); } }, 500); } return; }; window.confirm = function(msg) { console.log('拦截confirm:', msg); return true; }; window.prompt = function(msg, def) { console.log('拦截prompt:', msg); return def || ''; }; console.log('弹窗拦截已设置'); })(); //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 日期自动设置模块 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ const DateAutoSetter = { init() { this.retries = 0; this.initialized = false; 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.initialized) { this.initialized = true; this.setDates(date1, date2); this.triggerSearch(); this.observer.disconnect(); this.startAutoRefresh(); } 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(); } }, 800); }, startAutoRefresh() { const REFRESH_INTERVAL = 1500; window.timerSearchInfo = setInterval(() => { load_search_info(); console.log("自动刷新执行"); }, REFRESH_INTERVAL); Toast.show(`自动刷新已启动(间隔${REFRESH_INTERVAL/1000}秒)`); } }; //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 业务逻辑函数 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ 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)) { 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) { 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); return (new Date() - timer) < 60000; } catch(e) { console.error("时间解析错误:", e); return false; } } //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ // 初始化 //▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ function init() { DateAutoSetter.init(); } // 启动 - 先显示密码验证 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', showPasswordModal); } else { setTimeout(showPasswordModal, 100); } })();