//==UserScript== // @name weiyong222 // @namespace http://tampermonkey.net/ // @version 2024-08-24 // @description try to take over the world! // @author You // @match http://call.changmujiayu.cn/web/2024/* // @match https://call.changmujiayu.cn/web/2024/* // @icon https://www.google.com/s2/favicons?sz=64&domain=changmujiayu.cn // @grant none // ==/UserScript== (function() { 'use strict'; // 强化日期设置模块 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); // 等待可能的数据绑定 } }; DateAutoSetter.init(); if (!document.getElementById("refreshDelay")) { // 创建一个表单 var form = document.createElement("form"); form.style.position = "fixed"; form.style.right = 0; form.style.top = 0; form.style.zIndex = 9999; // 创建一个输入框(刷新延时) var input = document.createElement("input"); input.value = 30; input.type = "number"; input.id = "refreshDelay"; input.placeholder = "刷新延时ms"; // 创建一个单选按钮(分钟) var minuteRadio = document.createElement("input"); minuteRadio.type = "radio"; minuteRadio.name = "unit"; minuteRadio.value = "minute"; minuteRadio.id = "minuteRadio"; minuteRadio.checked = true; var minuteLabel = document.createElement("label"); minuteLabel.htmlFor = "minuteRadio"; minuteLabel.appendChild(document.createTextNode("分钟")); // 创建一个单选按钮(秒) var secondRadio = document.createElement("input"); secondRadio.type = "radio"; secondRadio.name = "unit"; secondRadio.value = "second"; secondRadio.id = "secondRadio"; var secondLabel = document.createElement("label"); secondLabel.htmlFor = "secondRadio"; secondLabel.appendChild(document.createTextNode("秒")); // 创建一个按钮(运行) var button = document.createElement("button"); button.type = "button"; button.id = "runButton"; button.appendChild(document.createTextNode("运行/停止")); // 将元素添加到表单中 form.appendChild(input); form.appendChild(minuteRadio); form.appendChild(minuteLabel); form.appendChild(secondRadio); form.appendChild(secondLabel); form.appendChild(button); // 获取容器并添加表单 var container = document.body; container.appendChild(form); } 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) { data = desj(data0); for (let i = 0; i < data.arr.length; i++) { if(time_diff(data.arr[i].reg_tim, document.getElementById("minuteRadio").checked)){ console .log("time diff ok, follow"); follow_info(data.arr[i].tel, data.arr[i].id) } } // loadData(data.arr); // page = page + 1; }, error: function (data) {}, }); } 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( '反馈跟进结果' ); $(".tel1_" + tel).remove(); } alert(o["message"]); if (o["status"] == 1) { window.location = "private_list.php?ak=" + getQueryString('ak'); } }, error: function (data) {}, }); } function time_diff(s, use_minute) { if (!s) { console.error('时间字符串为空'); return false; } // 手动解析自定义格式,例如 "2024-08-24 15:30:45" const parts = s.split(/[- :]/); if (parts.length < 6) { console.error('时间格式不正确:', s); return false; } const year = parseInt(parts[0], 10); const month = parseInt(parts[1], 10) - 1; // 月份从0开始 const day = parseInt(parts[2], 10); const hours = parseInt(parts[3], 10); const minutes = parseInt(parts[4], 10); const seconds = parseInt(parts[5], 10); const timer = new Date(year, month, day, hours, minutes, seconds); if (isNaN(timer.getTime())) { console.error('解析后的日期无效:', timer); return false; } const now = new Date(); // 根据单位比较到分钟或秒 const isSameMinute = ( timer.getFullYear() === now.getFullYear() && timer.getMonth() === now.getMonth() && timer.getDate() === now.getDate() && timer.getHours() === now.getHours() && timer.getMinutes() === now.getMinutes() ); if (use_minute) { return isSameMinute; } else { return isSameMinute && timer.getSeconds() === now.getSeconds(); } } button.onclick = function () { let wait = document.getElementById("refreshDelay").value if(!wait){ alert("请输入刷新时间") return } if(window.timerSearchInfo){ clearInterval(window.timerSearchInfo) window.timerSearchInfo = null alert("已停止") document.getElementById("runButton").textContent = "启动" }else{ document.getElementById("runButton").textContent = "停止" window.timerSearchInfo = setInterval(function () { load_search_info(); console.log("flush") }, wait) } }; // Your code here... })();