CSDN禁止弹窗+允许复制,隐藏页面上一切无用的信息,还你一个干净的CSDN

向csdn宣战

// ==UserScript==
// @name         CSDN禁止弹窗+允许复制,隐藏页面上一切无用的信息,还你一个干净的CSDN
// @namespace    http://tampermonkey.net/
// @version      1.0.0.1
// @description  向csdn宣战
// @author       lalaki
// @match        https://*.csdn.net/*
// @icon         https://www.csdn.net/favicon.ico
// @homepage     lalaki.cn
// @license      MIT
// @run-at       document-start
// ==/UserScript==
(function () {
	"use strict";
	const style = document.createElement("style");
	style.innerHTML = `#article_content{overflow:auto !important}.bar-content .time{font-size:unset !important}#mainBox main{position:absolute;left:0 !important;top:0 !important;z-index:2147483646 !important}@media screen and (min-width: 1px) {.nodata .container{width:auto !important;}}.article_content{height:auto !important},#content_views .hl-1{background-image:unset !important;margin:0 0 0 0 !important;padding:0 0 0 0 !important;color:unset !important}.set-code-hide{max-height:unset !important;height:auto !important}#getVipUrl{transform: scale(2.5);bottom: 50px;}.hide-article-pos{position:fixed !important;left:0}#blogVoteBox,#treeSkill,#recommend,.m_toolbar_left_app_btn,.m_toolbar_left_copyright,.readall_box,.article-heard-img,.c-gray,.wap-shadowbox,.feed-Sign-weixin,.ios-shadowbox,.openApp,#operate,.hide-article-pos,#blogHuaweiyunAdvert,.ai-article-tag,#blogColumnPayAdvert,a.logo,img.logo,.vip-icon,.blog_container_aside,.blog-tags-box,.left-toolbox,.hide-preCode-box,.btn-tag,.article-vip-img-new,.el-popover__reference-wrapper,.show-more-introduction-fold,.person-code-age,.user-profile-icon,.user-profile-body-left{display:none !important;position:absolute;top:-999px;left:-999px}.toolbar-container-right{display:none !important}#blog_extension{display:none !important}.body-show-la{opacity: 0;transition:opacity 0.5s ease}.body-show-la.show{opacity:1;}.passport-login-tip-container{display:none!important}#mainBox main{width:100%!important}.recommend-box{display:none!important}#toolbarBox,.hljs-button.signin.active,.article-search-tip,.passport-login-container,.passport-login-box{display:none!important}*{user-select:auto!important}#passportbox,.passport-login-container{pointer-events:none;display:none;position:fixed;top:-99999px!important;left:-9999px!important}.csdn-side-toolbar{display:none!important}#copyright-box{display:none;position:absolute;left:-999px;bottom:-2222px}.blog-footer-bottom{position:fixed;bottom:-9999px}.hljs-button.signin.active.blog-footer-bottom{display:none !important}`;
	document.head.prepend(style);
	const script = document.createElement("script");
	script.innerHTML = `
window.onload = () => {
	document.body.className += " body-show-la";
	function loopDom(ele) {
		const children = ele.children;
		const computedStyles = window.getComputedStyle(ele);
		if (computedStyles.userSelect === "none") {
			ele.style.userSelect = "auto";
		}
		const className = ele.className + "";
		const id = ele.id;
		if (
			(id.startsWith("blog") && id.endsWith("Advert")) ||
			id == "treeSkill" ||
			id == "toolbarBox" ||
			id == "copyright-box" ||
			className.indexOf("csdn-side-toolbar") != -1 ||
			className.indexOf("more-toolbox-new") != -1 ||
			className.indexOf("blog_container_aside") != -1 ||
			className.indexOf("recommend-box") != -1 ||
			className.indexOf("blog-footer-bottom") != -1 ||
			className.indexOf("hljs-button signin active") != -1
		) {
			ele.remove();
		} else if (className.indexOf("hide-preCode-bt") != -1) {
			ele.click();
		}
		ele.oncontextmenu = "return true";
		ele.oncopy = (event) => {
			const selectedText = window.getSelection().toString();
			event.clipboardData.setData("text/plain", selectedText);
			event.preventDefault();
			return true;
		};
		for (let i = 0; i < children.length; i++) {
			loopDom(children[i]);
		}
	}
	loopDom(document.body);
	let errCount = 0;
	const task = setInterval(() => {
		try {
			document.querySelector(".blog-footer-bottom").remove();
			document
				.querySelectorAll(".hljs-button.signin.active")
				.forEach((it) => it.remove());
			document.body.classList.toggle("show");
			clearInterval(task);
		} catch (e) {
			if (errCount > 200) {
				document.body.classList.toggle("show");
				clearInterval(task);
			}
			errCount++;
		}
	}, 1);
};
`;
	document.head.append(script);
})();