禁用CSDN背景

禁用CSDN背景,防止动态背景导致CPU占用过高

Stan na 15-08-2023. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         禁用CSDN背景
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  禁用CSDN背景,防止动态背景导致CPU占用过高
// @author       vertexz、ChatGPT
// @match        https://blog.csdn.net/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=csdn.net
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var style = document.createElement('style');
    style.innerHTML = `
    * {
        animation: none !important;
        transition: none !important;
    }
    body {
        background-image: none !important;
    }
    `;
    document.head.appendChild(style);

    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            var addedNodes = mutation.addedNodes;
            for (var i = 0; i < addedNodes.length; i++) {
                var node = addedNodes[i];
                if (node.getAttribute != undefined && node.getAttribute("style") != null && node.getAttribute("style").includes("animation")) {
                    node.style.animation = "none";
                }
                if (node.getAttribute != undefined && node.getAttribute("style") != null && node.getAttribute("style").includes("transition")) {
                    node.style.transition = "none";
                }
            }
        });
    });

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