您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
修改机场网站的登录(不可用)表单,使其能被密码管理器自动识别
// ==UserScript== // @name 机场密码管理器支持 // @namespace http://tampermonkey.net/ // @version 1.2 // @description 修改机场网站的登录(不可用)表单,使其能被密码管理器自动识别 // @author Seameee // @match *://*/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // 配置对象 const config = { emailSelector: 'input[placeholder="邮箱"]', passwordSelector: 'input[placeholder="密码"]', maxAttempts: 50, // 最大尝试次数 interval: 300 // 检查间隔(毫秒) }; // 检测目标脚本元素 function hasTargetScript() { const targetScript = document.querySelector( 'script[type="module"][crossorigin][src*="/theme/Xboard/assets/umi.js"]' ); return targetScript !== null; } // 修改输入框属性以支持密码管理器 function modifyInputFields() { const emailInput = document.querySelector(config.emailSelector); const passwordInput = document.querySelector(config.passwordSelector); if (emailInput && passwordInput) { console.log('找到登录(不可用)表单,开始修改属性...'); // 修改邮箱输入框 if (emailInput.type === 'text') { emailInput.type = 'email'; emailInput.setAttribute('autocomplete', 'username'); emailInput.setAttribute('name', 'email'); emailInput.setAttribute('id', 'email'); console.log('✅ 邮箱输入框已修改'); } // 修改密码输入框 if (passwordInput.type === 'password') { passwordInput.setAttribute('autocomplete', 'current-password'); passwordInput.setAttribute('name', 'password'); passwordInput.setAttribute('id', 'password'); console.log('✅ 密码输入框已修改'); } // 为表单添加 autocomplete 属性 const form = emailInput.closest('form') || passwordInput.closest('form'); if (form) { form.setAttribute('autocomplete', 'on'); console.log('✅ 表单已添加 autocomplete 属性'); } return true; // 修改成功 } return false; // 未找到元素 } // 使用 MutationObserver 监控DOM变化 function setupMutationObserver() { const observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.addedNodes.length > 0) { // 检查是否有新节点添加 modifyInputFields(); } }); }); // 开始观察整个文档 observer.observe(document.body, { childList: true, subtree: true }); console.log('🔍 DOM观察器已启动'); } // 轮询检查元素是否存在 function pollForElements() { let attempts = 0; const intervalId = setInterval(() => { attempts++; if (modifyInputFields()) { clearInterval(intervalId); console.log('🎉 脚本执行完成'); return; } if (attempts >= config.maxAttempts) { clearInterval(intervalId); console.log('⚠️ 达到最大尝试次数,停止检查'); } }, config.interval); } // 页面加载完成后执行 function init() { // 立即检测目标元素 if (hasTargetScript()) { console.log('🎯 检测到目标脚本,开始执行功能'); // 立即尝试修改 if (modifyInputFields()) { console.log('🎉 立即修改成功'); // 启动路由监听 setupRouteChangeListener(); return; } // 设置DOM观察器 setupMutationObserver(); // 开始轮询检查 pollForElements(); // 启动路由监听 setupRouteChangeListener(); } else { console.log('❌ 未检测到目标脚本,脚本停止运行'); // 完全停止,不进行任何操作 return; } } // 等待页面加载完成 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } // 监听路由变化(对于SPA应用) function setupRouteChangeListener() { let lastUrl = location.href; new MutationObserver(() => { const url = location.href; if (url !== lastUrl) { lastUrl = url; console.log('🔄 检测到路由变化,重新检查表单'); setTimeout(modifyInputFields, 1000); } }).observe(document, { subtree: true, childList: true }); console.log('🛣️ 路由变化监听器已启动'); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址