您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Save and restore input values from localStorage
// ==UserScript== // @name wcm发布文档页Input Value Saver // @namespace http://tampermonkey.net/ // @version 1.0 // @description Save and restore input values from localStorage // @author Your Name // @match http://10.5.41.14:8181/wcm/app/document/document_addedit.jsp?* // @match http://10.207.19.118:7001/wcm/app/document/document_addedit.jsp?* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // 定义输入框的ID const inputIds = ['ZHONGSHEN', 'FUSHEN', 'CHUSHEN']; // 检查三个输入框是否全部为空 const allInputsEmpty = inputIds.every(id => { const inputElement = document.getElementById(id); return inputElement && inputElement.value.trim() === ''; }); if (allInputsEmpty) { console.log('所有输入框都为空,继续执行其他操作...'); // 这里可以继续执行其他操作 // 从localStorage读取并填充输入框 inputIds.forEach(id => { const savedValue = localStorage.getItem(id); if (savedValue !== null) { document.getElementById(id).value = savedValue; } }); } // 监听输入事件,将值存储到localStorage inputIds.forEach(id => { const inputElement = document.getElementById(id); if (inputElement) { inputElement.addEventListener('input', () => { localStorage.setItem(id, inputElement.value); }); } }); })();