自动填写jscs

自动填写jscb

Bu script direkt olarak kurulamaz. Başka scriptler için bir kütüphanedir ve meta yönergeleri içerir // @require https://update.greasyfork.org/scripts/492752/1361748/%E8%87%AA%E5%8A%A8%E5%A1%AB%E5%86%99jscs.js

// ==UserScript==
// @name         自动填写
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  美化
// @author       你猜
// @match        https://static.jnb.icbc.com.cn/ICBC/ICBCCOIN/roccentry.html
// @grant        none
//==/UserScript==

(function() {
    'use strict';

    let userInfo = [
        { name: '张三', id: '123456789', phone: '13800000000', quantity: '1' }
        // 添加更多初始信息...
    ];

    function createInterface() {
        let container = document.createElement('div');
        container.setAttribute('style', `
            position: fixed; top: 20px; right: 20px;
            background-color: #f0f0f0;
            border: 1px solid #ccc;
            padding: 20px;
            z-index: 10000;
            width: 300px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
            font-family: 'Arial', sans-serif;
        `);

        let selectHTML = userInfo.map((info, index) => `<option value="${index}">${info.name} - ${info.phone}</option>`).join('');
        container.innerHTML = `
            <div style="margin-bottom: 12px; font-size: 16px; font-weight: bold;">选择预录入信息:</div>
            <select id="userInfoSelect" style="width: 100%; padding: 8px; border-radius: 4px; border: 1px solid #ccc; margin-bottom: 12px;">${selectHTML}</select>
            <button id="fillButton" style="width: 100%; padding: 10px; border: none; border-radius: 4px; background-color: #4CAF50; color: white; margin-bottom: 8px;">填写信息</button>
            <button id="deleteButton" style="width: 100%; padding: 10px; border: none; border-radius: 4px; background-color: #f44336; color: white; margin-bottom: 12px;">删除信息</button>
            <div style="margin-bottom: 8px; font-size: 16px; font-weight: bold;">添加新的信息:</div>
            <input type="text" id="newName" placeholder="姓名" style="width: 100%; padding: 8px; border-radius: 4px; border: 1px solid #ccc; margin-bottom: 8px;">
            <input type="text" id="newId" placeholder="证件号码" style="width: 100%; padding: 8px; border-radius: 4px; border: 1px solid #ccc; margin-bottom: 8px;">
            <input type="text" id="newPhone" placeholder="手机号码" style="width: 100%; padding: 8px; border-radius: 4px; border: 1px solid #ccc; margin-bottom: 8px;">
            <input type="text" id="newQuantity" placeholder="预约数量" style="width: 100%; padding: 8px; border-radius: 4px; border: 1px solid #ccc; margin-bottom: 8px;">
            <button id="addInfoButton" style="width: 100%; padding: 10px; border: none; border-radius: 4px; background-color: #008CBA; color: white;">添加信息</button>
        `;

        document.body.appendChild(container);

        // 绑定按钮事件
        document.getElementById('fillButton').addEventListener('click', fillForm);
        document.getElementById('addInfoButton').addEventListener('click', addInfo);
        document.getElementById('deleteButton').addEventListener('click', deleteInfo);
    }

    // 填写表单逻辑
    function fillForm() {
        let selectedInfo = userInfo[document.getElementById('userInfoSelect').value];
        // 填写逻辑,根据实际表单元素修改
        document.querySelector('input[name="客户姓名"]').value = selectedInfo.name;
        document.querySelector('input[name="证件号码"]').value = selectedInfo.id;
        document.querySelector('input[name="手机号码"]').value = selectedInfo.phone;
        document.querySelector('input[name="预约数量"]').value = selectedInfo.quantity;
    }

    // 添加新信息逻辑
    function addInfo() {
        let newName = document.getElementById('newName').value.trim();
        let newId = document.getElementById('newId').value.trim();
        let newPhone = document.getElementById('newPhone').value.trim();
        let newQuantity = document.getElementById('newQuantity').value.trim();

        if (!newName || !newId || !newPhone || !newQuantity) {
            alert('请填写所有字段');
            return;
        }

        let newUserInfo = { name: newName, id: newId, phone: newPhone, quantity: newQuantity };
        userInfo.push(newUserInfo);

        updateSelectOptions();
        clearInputs();
    }

    // 删除信息逻辑
    function deleteInfo() {
        let selectedIndex = document.getElementById('userInfoSelect').value;
        if (selectedIndex >= 0) {
            userInfo.splice(selectedIndex, 1); // 从数组中删除选中的信息
            updateSelectOptions();
        } else {
            alert('请选择要删除的信息');
        }
    }

    // 更新下拉列表选项
    function updateSelectOptions() {
        let select = document.getElementById('userInfoSelect');
        select.innerHTML = userInfo.map((info, index) => `<option value="${index}">${info.name} - ${info.phone}</option>`).join('');
    }

    // 清除输入框
    function clearInputs() {
        document.getElementById('newName').value = '';
        document.getElementById('newId').value = '';
        document.getElementById('newPhone').value = '';
        document.getElementById('newQuantity').value = '';
    }

    createInterface(); // 调用函数以创建界面
})();