隐藏基于样式渲染的网页水印,不依赖具体文字内容
// ==UserScript==
// @name 通用网页水印屏蔽器(结构特征识别)
// @namespace https://chat.openai.com/
// @version 1.1
// @description 隐藏基于样式渲染的网页水印,不依赖具体文字内容
// @match *://*.didichuxing.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function () {
'use strict';
const hideStyle = document.createElement('style');
hideStyle.innerHTML = `
/* 常见水印结构样式 */
[style*="opacity: 0.1"],
[style*="opacity:0.1"],
[style*="opacity: 0.05"],
[style*="opacity:0.05"],
[style*="user-select: none"][style*="pointer-events: none"],
[style*="pointer-events: none"][style*="fixed"],
[style*="pointer-events: none"][style*="absolute"],
[style*="z-index: 9999"],
[class*="watermark"],
.watermark {
display: none !important !important;
visibility: hidden !important;
}
`;
document.head.appendChild(hideStyle);
// 删除疑似水印元素(不看内容,只看样式)
function removeStyleBasedWatermarks() {
const all = document.querySelectorAll('*');
all.forEach(el => {
const style = getComputedStyle(el);
const isWatermarkLike =
(style.opacity < 0.2) &&
(style.pointerEvents === 'none') &&
(style.userSelect === 'none' || style.position === 'fixed' || style.position === 'absolute') &&
(parseInt(style.zIndex) >= 9999 || style.zIndex === 'auto');
const sizeOK =
el.offsetWidth >= 100 && el.offsetHeight >= 40;
if (isWatermarkLike && sizeOK) {
el.remove();
console.log('✅ 移除结构样式型水印:', el);
}
});
}
// 连续尝试 + 动态监听
const timer = setInterval(removeStyleBasedWatermarks, 300);
setTimeout(() => clearInterval(timer), 5000);
const observer = new MutationObserver(removeStyleBasedWatermarks);
observer.observe(document, { childList: true, subtree: true });
})();