修改CSDN博客页面的样式和移除一些元素
// ==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();
}
})();