CSDN超强防护

自动展开全部内容,免登录复制,去除广告,增加搜索框,手机端专用。

当前为 2023-06-17 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         CSDN超强防护
// @namespace    https://viayoo.com/
// @version      0.4
// @description  自动展开全部内容,免登录复制,去除广告,增加搜索框,手机端专用。
// @author       呆毛飘啊飘
// @run-at       document-end
// @match        *://*.csdn.net/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {

//屏蔽元素
document.querySelectorAll(".feed-Sign-weixin,.feed-Sign-span,.blind_box,.loginFnAdd,.icon-line,.loginTag,.openApp,.add-firstAd,.passport-login-container,.follow,.readall_box,.m_toolbar_left_app_btn,.openApp,.btn_open_app_prompt_item,.passport-login-mark,.weixin-shadowbox,.wap-shadowbox").forEach(e=>e.remove());

//用于复制的函数
function copyText(txt) {
var x=document.body.scrollTop;
var y=document.documentElement.scrollTop;
const ta = document.createElement('textarea');
ta.value = txt;
ta.style.position = 'absolute';
ta.style.opacity = '0';
ta.style.left = '-999999px';
ta.style.top = '-999999px';
document.body.appendChild(ta);
ta.focus();
ta.select();
document.execCommand('copy');
document.body.removeChild(ta);
window.scrollTo(x,y);
};

//展开所有代码块内容
$('.hide-preCode-bt').click();

//修改按钮使不登录可以复制
$(".hljs-button").attr("data-title", "直接复制");
$(".hljs-button").click(function(){copyText(this.parentNode.innerText);
$(".hljs-button").attr("data-title", "复制成功");
setTimeout(function(){$(".hljs-button").attr("data-title", "直接复制");},1500);});

//添加搜索框
var cdstyle = document.createElement("style");
cdstyle.type = "text/css";
cdstyle.innerHTML = ".article_content{overflow:visible !important; height:auto !important;}#sskbj{position: fixed;width:100%; height:35px; display: flex;z-index: 10000;top:6px;right:0px;}#sskbj input[type=text] {width: 20%;position: fixed;right:10%;height:40px;box-sizing: border-box;border: 2px solid #ccc;border-radius: 4px;font-size: 16px;background-color: white;padding: 12px 12px 12px 12px;-webkit-transition: width 0.4s ease-in-out;transition: width 0.4s ease-in-out;}#sskbj input[type=text]:focus {width:80%;}";
document.body.appendChild(cdstyle);
var divv = document.createElement("div");
divv.id = "sskbj";
divv.innerHTML = "<form action='https://so.csdn.net/wap'><input type='text' name='q' placeholder='搜索..'></form>";
document.body.appendChild(divv);

})();