CSDN免登录脚本
【摘要】 csdn免登录脚本
csdn免登录脚本
// ==UserScript==
// @name CSDN免登录脚本
// @namespace xyw
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*.csdn.net/*
// @icon https://www.google.com/s2/favicons?domain=baidu.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
//免登录一键复制
//hljs
[...document.querySelectorAll(".signin")].forEach( i => {i.onclick = hljs.copyCode})
//mdcp
document.querySelectorAll(".has-numbering").forEach( i => {i.onclick = mdcp.copyCode})
//免登录代码选中
document.querySelectorAll("#content_views pre code").forEach(s=>{
s.style.userSelect="text"
})
//免登录查看评论
setTimeout(()=>{
document.querySelectorAll(".comment-list-box")[0].removeAttribute("style")
document.querySelector("#commentPage").classList.remove("d-none")
document.getElementsByClassName("opt-box text-center")[0].remove()
},1000)
//免关注查看博客
document.querySelector("#article_content").removeAttribute("style")
document.getElementsByClassName("hide-article-box hide-article-pos text-center")[0].remove()
})();
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description copy for csdn
// @author xuanyusan
// @match https://blog.csdn.net/*
// @icon
// @grant none
// ==/UserScript==
(function () {
'use strict';
//优化登陆后复制
$('code').css({'user-select':'unset'})
$('#content_views pre').css({'user-select':'unset'})
//移除readmore按钮,并显示全文
$('.hide-article-box').remove();
$('.article_content').css({'height':'initial'})
//去除复制后的copyright小尾巴
document.querySelectorAll('*').forEach(item=>{
item.oncopy = function(e) {
e.stopPropagation();
}})
setTimeout(_ => {
let st = document.createElement("style");
st.innerHTML = `
pre:hover .button-copy {
display: block;
}
code .button-copy {
margin: 2px 8px;
}
.button-copy {
display: none;
position: absolute;
right: 4px;
top: 4px;
font-size: 12px;
color: #ffffff;
background-color: #9999AA;
padding: 2px 8px;
margin: 8px;
border-radius: 4px;
cursor: pointer;
box-shadow: 0 2px 4px rgb(0 0 0 / 5%), 0 2px 4px rgb(0 0 0 / 5%);
}
`
document.head.append(st);
document.querySelectorAll("pre").forEach(pitem => {
let sign = pitem.querySelector(".signin");
if (sign && sign.parentElement == pitem) {
pitem.removeChild(sign);
}
let item = pitem.querySelector("code");
sign = item.querySelector(".signin");
if (sign && sign.parentElement == item) {
item.removeChild(sign);
}
let btn = document.createElement("span");
btn.className = "button-copy";
btn.innerText = "复制文本";
btn.onclick = _ => {
let area = document.createElement("textarea");
area.value = item.innerText.replace(/复制文本$/,"");
item.appendChild(area);
area.select();
document.execCommand("Copy");
item.removeChild(area);
btn.innerText = "复制成功";
setTimeout(_ => {
btn.innerText = "复制文本";
}, 3000);
}
item.append(btn);
});
}, 1000);
//免登录代码选中
document.querySelectorAll("#content_views pre code").forEach(s=>{
s.style.userSelect="text"
})
//免登录查看评论
setTimeout(()=>{
document.querySelectorAll(".comment-list-box")[0].removeAttribute("style")
document.querySelector("#commentPage").classList.remove("d-none")
document.getElementsByClassName("opt-box text-center")[0].remove()
},1000)
//免关注查看博客
document.querySelector("#article_content").removeAttribute("style")
document.getElementsByClassName("hide-article-box hide-article-pos text-center")[0].remove()
})();
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)