Greasy Fork

Greasy Fork is available in English.

去除吉利SRM4.0页面全屏水印

尝试移除吉利SRM4.0页面全屏水印

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         去除吉利SRM4.0页面全屏水印
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  尝试移除吉利SRM4.0页面全屏水印
// @author       You
// @match        *://*/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 方式1:通过CSS样式移除
    const removeByCss = () => {
        const style = document.createElement('style');
        style.textContent = `
            [class*="watermark"],
            [id*="watermark"] {
                display: none !important;
            }
            /* 添加更多可能的水印选择器 */
        `;
        document.head.appendChild(style);
    };

    // 方式2:直接删除DOM元素
    const removeElements = () => {
        const selectors = [
            'div.watermark',
            '[class*="watermark"]',
            '[id*="watermark"]',
            // 添加更多可能的选择器
        ];

        selectors.forEach(selector => {
            document.querySelectorAll(selector).forEach(el => {
                el.parentNode.removeChild(el);
                console.log('已移除水印元素:', selector);
            });
        });
    };

    // 方式3:处理背景水印
    const removeBgWatermark = () => {
        document.querySelectorAll('*').forEach(el => {
            const bg = window.getComputedStyle(el).backgroundImage;
            if (bg.includes('watermark')) {
                el.style.backgroundImage = 'none';
            }
        });
    };

    // 方式4:使用MutationObserver监听动态加载的水印
    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            mutation.addedNodes.forEach(node => {
                if (node.nodeType === 1 && (
                    node.classList.contains('watermark') ||
                    node.id.includes('watermark')
                )) {
                    node.remove();
                    console.log('动态水印已被移除');
                }
            });
        });
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    // 执行所有清除方法
    removeByCss();
    removeElements();
    removeBgWatermark();

    // 可选:阻止水印相关的网络请求
    if (typeof window.unsafeWindow === 'undefined') {
        window.unsafeWindow = window;
    }

    const originalOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
        if (url && url.includes('watermark')) {
            console.log('已阻止水印请求:', url);
            return;
        }
        originalOpen.apply(this, arguments);
    };
})();