CSDN超强防护

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

目前為 2024-02-13 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         CSDN超强防护
// @namespace    https://viayoo.com/
// @version      0.5
// @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%;};.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{display:none;}";
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);

})();