NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name 办公网弹窗关闭器 // @version 0.3 // @description OA系统专用脚本 // @author Roy Law // @license MIT // @match *://172.26.14.6:8888/* // @exclude https://172.26.14.6:8888/MicrovideoCAS/login* // @icon https://img.icons8.com/ultraviolet/2x/resize.png // @grant none // @noframes // ==/UserScript== window.addEventListener ("load", LocalMain, false); function LocalMain () { // Your code goes here. var checkExist; // 定时器的引用 var lastFoundTime = Date.now(); // 记录上次找到按钮的时间 function checkAndCloseButtons() { var closeButtons = document.querySelectorAll('a.aui_close'); if (closeButtons.length > 0 && Date.now() - lastFoundTime < 3000) { console.log('找到按钮'); // 更新最后找到按钮的时间 //lastFoundTime = Date.now(); // 点击所有找到的关闭按钮 closeButtons.forEach(button => button.click()); } else if (Date.now() - lastFoundTime > 3000) { // 如果超过8秒钟没有发现新的按钮,清除定时器 clearInterval(checkExist); console.log('停止计时器'); return; } } // 每500毫秒检查一次按钮 checkExist = setInterval(checkAndCloseButtons, 800); console.log('初始化计时器'); }