From 4971824216f4aa81838de115b5beab43f171e6ff Mon Sep 17 00:00:00 2001 From: 8ga Date: Wed, 25 Feb 2026 10:36:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E4=B8=AD=E5=9B=BD=E8=82=BF=E7=98=A4=E7=94=9F=E7=89=A9=E6=B2=BB?= =?UTF-8?q?=E7=96=97=E6=9D=82=E5=BF=97=E7=9A=84=E5=BC=B9=E7=AA=97.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 移除中国肿瘤生物治疗杂志的弹窗.js | 59 +++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 移除中国肿瘤生物治疗杂志的弹窗.js diff --git a/移除中国肿瘤生物治疗杂志的弹窗.js b/移除中国肿瘤生物治疗杂志的弹窗.js new file mode 100644 index 0000000..7197380 --- /dev/null +++ b/移除中国肿瘤生物治疗杂志的弹窗.js @@ -0,0 +1,59 @@ +// ==UserScript== +// @name 移除中国肿瘤生物治疗杂志的弹窗 +// @namespace http://tampermonkey.net/ +// @version 1.0 +// @description 移除中国肿瘤生物治疗杂志的弹窗 +// @author 8ga +// @match https://www.biother.cn/* +// @grant none +// @run-at document-end +// ==/UserScript== + +(function() { + 'use strict'; + + // 定义要移除的元素 ID + const targetId = 'MoveImagesWindowDiv'; + + // 移除元素的函数 + function removeElement() { + const element = document.getElementById(targetId); + if (element) { + element.remove(); + console.log('油猴脚本成功移除元素:', targetId); + return true; + } + return false; + } + + // 1. 尝试立即移除(针对静态加载或已加载的元素) + removeElement(); + + // 2. 设置观察器(针对动态加载的元素) + // 如果页面是通过 AJAX 或延迟加载该 div,观察器能确保它一出现就被移除 + const observer = new MutationObserver(() => { + if (removeElement()) { + // 如果成功移除,可以选择断开观察器以节省性能,或者保留它以应对元素被重新添加的情况 + // observer.disconnect(); + } + }); + + // 开始观察 body 节点的子节点变化 + if (document.body) { + observer.observe(document.body, { + childList: true, + subtree: true + }); + } else { + // 如果 body 还没加载(虽然 @run-at document-end 通常能保证 body 存在),等待 DOMContentLoaded + document.addEventListener('DOMContentLoaded', () => { + if (document.body) { + observer.observe(document.body, { + childList: true, + subtree: true + }); + removeElement(); + } + }); + } +})(); \ No newline at end of file