// ==UserScript== // @name XY自动提交 // @namespace http://tampermonkey.net/ // @version 1 // @description 自动填写跟进备注并提交表单,不跳转不弹窗 // @author You // @match https://hw.jst2024.cn/web/2024/* // @grant none // @run-at document-start // ==/UserScript== (function() { 'use strict'; // 屏蔽所有弹窗 window.alert = function() { return true; }; window.confirm = function() { return true; }; window.prompt = function() { return ''; }; window.onbeforeunload = null; window.onunload = null; // 自动填写并提交表单 function autoFillAndSubmit() { setTimeout(function() { try { var contentInput = document.querySelector('input[name="content"]'); if (contentInput) { contentInput.value = '1'; contentInput.setAttribute('value', '1'); // 触发事件 contentInput.dispatchEvent(new Event('input', { bubbles: true })); contentInput.dispatchEvent(new Event('change', { bubbles: true })); // 延迟提交 setTimeout(function() { var form = document.querySelector('form'); if (form) { try { // 简单的fetch提交,不处理响应,不跳转 var formData = new FormData(form); formData.set('content', '1'); fetch(form.action || window.location.href, { method: 'POST', body: formData, keepalive: true }).catch(function() {}); // 备用方法:直接点击提交按钮 setTimeout(function() { try { var submitBtn = document.querySelector('input[type="submit"]'); if (submitBtn) { submitBtn.click(); } } catch (e) {} }, 300); } catch (e) {} } }, 200); } } catch (error) {} }, 500); } // 等待页面加载 function waitForPage() { if (window.location.href.includes('private_edit.php')) { autoFillAndSubmit(); } } // 页面加载完成后执行 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', waitForPage); } else { waitForPage(); } // 监听页面变化 let lastUrl = location.href; new MutationObserver(() => { if (location.href !== lastUrl && location.href.includes('private_edit.php')) { lastUrl = location.href; setTimeout(autoFillAndSubmit, 1000); } }).observe(document, {subtree: true, childList: true}); })();