CSDN去登录、去关注看全文、去登录粘贴代码、去代码折叠、去vip查看文章

修改CSDN博客页面的样式和移除一些元素

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         CSDN去登录、去关注看全文、去登录粘贴代码、去代码折叠、去vip查看文章
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  修改CSDN博客页面的样式和移除一些元素
// @author       去除CSDN关注查看全文
// @match        https://blog.csdn.net/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 移除article_content的style属性
    var article_content = document.getElementById("article_content");
    if (article_content) {
        article_content.removeAttribute("style");
    }

    // 移除follow-text元素
    var follow_text = document.getElementsByClassName('follow-text')[0];
    if (follow_text && follow_text.parentElement && follow_text.parentElement.parentElement) {
        follow_text.parentElement.parentElement.removeChild(follow_text.parentElement);
    }

    // 移除hide-article-box元素
    var hide_article_box = document.getElementsByClassName('hide-article-box')[0];
    if (hide_article_box && hide_article_box.parentElement) {
        hide_article_box.parentElement.removeChild(hide_article_box);
    }

    // 移除登录弹窗
    var loginContainer = document.querySelector('.passport-login-container');
    if (loginContainer) {
        loginContainer.remove();
    }
    // 函数用于展开隐藏的代码块
    function expandCodeBlocks() {
        const hideCodeButtons = document.querySelectorAll('.hide-preCode-bt');
        hideCodeButtons.forEach(button => {
            button.click();
        });
    }

    // 检查页面是否加载完成,然后执行展开操作
    if (document.readyState === "loading") {
        document.addEventListener("DOMContentLoaded", expandCodeBlocks);
    } else {
        expandCodeBlocks();
    }
})();