// ==UserScript==
// @name 工商银行纪念币预约自动填表
// @namespace http://tampermonkey.net/
// @version 1.1
// @description 自动填充工商银行纪念币预约表单(含地区选择)
// @match *://*.icbc.com.cn/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const CONFIG = {
custName: '', // 客户姓名
paperNum: '', // 证件号码
mobileno: '', // 手机号码
exchangeQuanlity: '20', // 预约数量
province: '天津市', // 省份
city: '天津市', // 城市
district: '静海区', // 区县
branch: '', // 网点
exchangeTime: '2026-01-20' // 兑换时间
};
// ================================================
function fillInput(placeholder, value) {
const inputs = document.querySelectorAll('input.el-input__inner');
for (const input of inputs) {
if ((input.placeholder || '').includes(placeholder)) {
input.value = value;
input.dispatchEvent(new Event('input', { bubbles: true }));
return true;
}
}
return false;
}
async function selectDropdown(placeholder, optionText) {
const inputs = document.querySelectorAll('input.el-input__inner[readonly]');
for (const input of inputs) {
if ((input.placeholder || '').includes(placeholder)) {
input.click();
await new Promise(r => setTimeout(r, 1));
const items = document.querySelectorAll('.el-select-dropdown__item:not(.is-disabled)');
for (const item of items) {
if (item.textContent.includes(optionText)) {
item.click();
await new Promise(r => setTimeout(r, 1));
return true;
}
}
}
}
return false;
}
async function fillForm() {
// 填充文本输入框
fillInput('客户姓名', CONFIG.custName);
fillInput('证件号码', CONFIG.paperNum);
fillInput('手机号码', CONFIG.mobileno);
fillInput('预约数量', CONFIG.exchangeQuanlity);
// 填充下拉选择框
await selectDropdown('省份', CONFIG.province);
await selectDropdown('城市', CONFIG.city);
await selectDropdown('区县', CONFIG.district);
await selectDropdown('网点', CONFIG.branch);
await selectDropdown('兑换时间', CONFIG.exchangeTime);
console.log('表单已填充');
}
function addButton() {
const btn = document.createElement('button');
btn.textContent = '手动填充';
btn.style.cssText = 'position:fixed;top:10px;right:10px;z-index:9999;padding:10px 20px;background:#409EFF;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:14px;';
btn.onclick = fillForm;
document.body.appendChild(btn);
}
window.addEventListener('load', () => {
addButton();
setTimeout(fillForm, 1500);
});
})();
📌 转载信息
原作者:
sam5440
转载时间:
2026/1/14 10:47:28