// ==UserScript==
// @name 知乎、简书、CSDN文章详情自动展开
// @namespace https://www.mumudroid.com/
// @version 0.1
// @description 代码示例
// @author You
// @match https://www.zhihu.com/question/*
// @match https://www.jianshu.com/p/*
// @match https://blog.csdn.net/*/article/details/*
// @exclude *login*
// @icon https://static.zhihu.com/heifetz/assets/apple-touch-icon-152.a53ae37b.png
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
setInterval(function(){
//知乎
if(location.hostname=='www.zhihu.com'){
console.log("open zhihu");
//展开
var commentLists = document.getElementsByClassName('RichContent-inner RichContent-inner--collapsed')
for(let item of commentLists) {
item.removeAttribute("style")
item.removeAttribute("class")
}
//去除按钮
var btnLists = document.getElementsByClassName('Button ContentItem-rightButton ContentItem-expandButton Button--plain')
for(let btn of btnLists) {
//console.log(btn);
btn.style.display='none';
}
}
//简书
else if(location.hostname == 'www.jianshu.com'){
var shadowbox = document.querySelector('body > div.download-app-guidance');
if(shadowbox){
//console.log('简书隐藏打开客户端弹出层');
shadowbox.style.display='none';
}
var element = document.querySelector('div.collapse-free-content');
if(element){
console.log('简书展开');
element.removeAttribute('class');
var btn = document.getElementsByClassName('collapse-tips')[0]
if(btn){
btn.style.display='none';
}
}
element = document.getElementsByClassName('guidance-wrap-conetnt')[0]
if(element){
element.style.display='none';
}
}
//CSDN
else if(location.hostname == 'blog.csdn.net'){
//隐藏打开APP阅读按钮
let gotoAppBtn = document.querySelector('#main > div.btn_open_app_prompt_div');
if(gotoAppBtn){
gotoAppBtn.style.display='none';
}
//隐藏浮动提示按钮(这个按钮会随机浮动刷新显示,很无语)
let gotoAppBtnFlow = document.querySelector('body > span.feed-Sign-span.feed-Sign-style-new.open_app_channelCode');
if(gotoAppBtnFlow){
gotoAppBtnFlow.style.display='none';
}
//关闭自动弹出的登录页面
//let loginPage = document.getElementsByClassName('passport-login-container')
let loginPage = document.querySelector('body > passport-login-container');
if(loginPage){
console.log('csdn隐藏登录页面');
loginPage.style.display='none';
}
//csdn隐藏打开客户端弹出层
shadowbox = document.querySelector('body > div.weixin-shadowbox.wap-shadowbox');
if(shadowbox){
console.log('csdn隐藏打开客户端弹出层');
shadowbox.style.display='none';
}
//csdn显示全部文章
element = document.querySelector('#csdn-previewimg-box > div');
if(element){
console.log('csdn展开');
element.removeAttribute('style');
}
//csdn隐藏关注展开按钮
element = document.querySelector('#article > div.readall_box');
if(element){
element.style.display='none';
}
}
}, 2000);//setInterval
})();
网页打开文章详情自动展开