您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
自动填充
当前为
// ==UserScript== // @name 自动填充表单 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 自动填充 // @author 72 // @match *://*/* // @grant none // ==/UserScript== (function() { 'use strict'; function getElementText(element) { return Array.from(element.childNodes) .map(child => child.nodeType === Node.TEXT_NODE ? child.textContent.trim() : getElementText(child)) .join(' ') .trim(); } function autofill() { let filled = false; document.querySelectorAll('label, div, span').forEach(element => { const text = getElementText(element); let fillValue; switch (true) { case /^(贴吧|ID|)$/.test(text): fillValue = '自动填充的名字'; break; case /^(姓名|姓名1)$/.test(text): fillValue = '香菜'; break; case /^(姓名2)$/.test(text): fillValue = '小王'; break; case /^(手机号|手机号1|手机号码|手机号码2)$/.test(text): fillValue = '110'; break; case /^(手机号2|手机号码2)$/.test(text): fillValue = '112'; break; case /^(身份证|身份证1身份证号码|身份证号码1)$/.test(text): fillValue = '320'; break; case /^(身份证2|身份证号码2)$/.test(text): fillValue = '220'; break; } if (fillValue !== undefined) { const inputField = element.closest('.ant-form-item, .ant-col')?.querySelector('input'); if (inputField) { inputField.value = fillValue; filled = true; console.log('Filled value:', fillValue, 'in input field.'); } else { console.log('Input field not found.'); } } }); // 滚动到页面底部 window.scrollTo(0, document.body.scrollHeight); return filled; } function attemptAutofill(retries = 20, delay = 500) { let attempt = 0; const tryFill = () => { if (autofill() || attempt >= retries) return; attempt++; setTimeout(tryFill, delay); }; tryFill(); } setTimeout(() => attemptAutofill(), 100); new MutationObserver(mutations => { mutations.forEach(mutation => { if (mutation.type === 'childList' || mutation.type === 'attributes') { attemptAutofill(); } }); }).observe(document.body, { attributes: true, childList: true, subtree: true }); window.addEventListener('load', () => { attemptAutofill(); window.scrollTo(0, document.body.scrollHeight); }); })();