diff --git a/移除SaToken的弹窗.js b/移除SaToken的弹窗.js new file mode 100644 index 0000000..5dc88a8 --- /dev/null +++ b/移除SaToken的弹窗.js @@ -0,0 +1,42 @@ +// ==UserScript== +// @name 移除SaToken的弹窗 +// @namespace http://tampermonkey.net/ +// @version 1.0 +// @description 移除SaToken的弹窗 +// @author 8ga +// @match https://sa-token.cc/* +// @grant none +// ==/UserScript== + +(function () { + 'use strict'; + + // 立即检查一次(防止页面已加载完成) + removePasswordModal(); + + // 使用 MutationObserver 监听 DOM 变化 + const observer = new MutationObserver((mutations) => { + for (const mutation of mutations) { + if (mutation.type === 'childList') { + // 如果新增节点中有目标元素,立即移除 + if (document.getElementById('passwordModal')) { + removePasswordModal(); + } + } + } + }); + + // 开始监听整个 document 的子节点变化(包括深层嵌套) + observer.observe(document.body, { + childList: true, + subtree: true + }); + + function removePasswordModal() { + const modal = document.getElementById('passwordModal'); + if (modal && modal.parentNode) { + console.log('[Tampermonkey] 已移除 passwordModal 弹窗'); + modal.remove(); + } + } +})(); \ No newline at end of file