// ==UserScript==
// @name CSDN超强防护
// @namespace https://viayoo.com/
// @version 0.3
// @description 自动展开全部内容,免登录复制,去除广告,增加搜索框,手机端专用。
// @author 呆毛飘啊飘
// @run-at document-start
// @run-at document-idle
// @match *://*.csdn.net/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
//屏蔽元素
document.querySelectorAll(".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);
})();
Back to home |
File page
Subscribe |
Register |
Login
| N