您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
支持【CSDN,简书,博客园,知乎,掘金,51CTO,51CTO文章,阿里云开发者社区,腾讯云开发者社区,微信,InfoQ,Github】等。 必要时临时关闭脚本,可能是需要验证。
当前为
// ==UserScript== // @name 只看博客内容 // @description 支持【CSDN,简书,博客园,知乎,掘金,51CTO,51CTO文章,阿里云开发者社区,腾讯云开发者社区,微信,InfoQ,Github】等。 必要时临时关闭脚本,可能是需要验证。 // @namespace https://gitee.com/inch_whf/tampermonkey-script-inch // @version 1.20 // @author wuhongfei // @license MIT // @grant none // @match *://blog.csdn.net/*/article/details/* // @match *://*.blog.csdn.net/article/details/* // @match *://www.jianshu.com/p/* // @match *://www.cnblogs.com/*/*/* // @match *://zhuanlan.zhihu.com/p/* // @match *://juejin.cn/post/* // @match *://blog.51cto.com/u_* // @match *://www.51cto.com/article/* // @match *://cloud.tencent.com/developer/article/* // @match *://bbs.huaweicloud.com/blogs/* // @match *://developer.aliyun.com/article/* // @match *://mp.weixin.qq.com/* // @match *://www.it610.com/article/* // @match *://www.infoq.cn/article/* // @match *://www.infoq.cn/news/* // @match *://github.com/*/*/issues/* // ==/UserScript== // 启动函数 (function(){ window.host = window.location.host; if(['www.infoq.cn','bbs.huaweicloud.com','www.cnblogs.com'].includes(host)){ window.onload=(()=>setTimeout(()=>{main(host)},1000)); // }else if(['juejin.cn','www.jianshu.com'].includes(host)){ }else { main(host); } })(); // 主函数 function main(host){ 'use strict'; // 删除标题中的冗余信息 removeInfo(); // 特制函数 zhihu(); csdn(); tencent_cloud(); const dom = get_dom (host); body_just_content(dom); dom_adjustment(dom); } // 去掉 (xx条消息) function removeInfo() { let title = document.getElementsByTagName("title")[0]; title.innerText = title.innerText.match(/(\([0-9]+.*[条](?=私信|消息).*?\)\s*)?(.+)/)[2]; } // 获得dom元素 function get_dom (host) { const map = { 'blog.csdn.net' :'#article_content', 'www.jianshu.com' :'div > div > div > div > section:nth-child(1) > article', 'www.cnblogs.com' :'#cnblogs_post_body', // https://www.cnblogs.com/intotw/p/13816056.html // 'www.cnblogs.com' :'div.post', // 'www.cnblogs.com' :'#topics > div', 'zhuanlan.zhihu.com' :'.RichText', 'juejin.cn' :'.markdown-body', 'blog.51cto.com' :'#page_center > article > div.common-section.common-spacing.mb30.article-detail > div.article-content-wrap', 'www.51cto.com' :'#__layout > div > section.index-set > div > div.article-left > article', 'developer.aliyun.com' :'body > div.article-detail > div.article-wrapper > div.left-content > div.content-wrapper', 'cloud.tencent.com' :'#react-root > div:nth-child(1) > div.J-body.col-body.pg-2-article > div.com-3-layout > div.layout-main > section.com-2-panel.col-2-article.J-articlePanel > div.com-markdown-collpase > div.com-markdown-collpase-main > div:nth-child(1) > div', 'bbs.huaweicloud.com' :'#blogContent', 'mp.weixin.qq.com' :'#img-content', 'www.it610.com' :'body > div:nth-child(3) > div > div > div.col-md-9', 'www.infoq.cn' :'.article-preview', 'github.com' :'#discussion_bucket > div > div.Layout-main', }; // 'zhuanlan.zhihu.com' :'#root > div > main > div > article', if(host.endsWith("blog.csdn.net")){ host = "blog.csdn.net"; } const selector = map[host]; const dom = document.querySelector(selector); return dom; } // 只保留内容dom function body_just_content (dom) { const body = document.body; // var dom2 = dom; // while(dom2.parentElement.tagName!='BODY'){ // dom2 = dom2.parentElement; // } // body.removeChild(dom2); const children = body.children for (var i = children.length - 1; i >= 0; i--) { if("LINK"!=children[i].tagName && "SCRIPT"!=children[i].tagName){ // if("DIV"==children[i].tagName){ body.removeChild(children[i]); } } body.appendChild(dom); } // 调整dom元素 function dom_adjustment(dom){ dom.style.width = '95%'; dom.style.margin = 'auto'; dom.style.display = 'block'; body = document.querySelector('body'); // body.style.background = ''; // https://blog.csdn.net/x619y/article/details/80604609 // body.style.setProperty('background', '#f5f6f7', 'important'); body.style.setProperty('background', 'rgba(18,18,18,0)', 'important'); // body.style.background-image = 'url("")'; // body.style.removeProperty('background-image'); const children2 = dom.children for (var i = children2.length - 1; i >= 0; i--) { children2[i].style.width = '100%'; // children2[i].style.margin = '0'; // children2[i].style.padding = '0'; // children2[i].style.border = '0'; } if (typeof window.orientation == 'undefined') { // 当前设备不是移动设备,限制宽度 // 参考:https://www.ruanyifeng.com/blog/2021/09/detecting-mobile-browser.html imgs = dom.getElementsByTagName("img"); for (var i = imgs.length - 1; i >= 0; i--) { imgs[i].style.width = ''; imgs[i].style.maxWidth = '50%'; imgs[i].style.display = 'block'; } // videos = dom.getElementsByTagName("video"); // for (var i = videos.length - 1; i >= 0; i--) { // videos[i].style.width = ''; // videos[i].style.maxWidth = '50%'; // } } } // 开始特制=========================================================================== // 知乎特制 function zhihu(){ if('zhuanlan.zhihu.com' != host){ return; } // 直接渲染所有图面 (function() { attribute = 'data-actualsrc'; imgs = document.querySelectorAll('img['+attribute+']'); for (var i = imgs.length - 1; i >= 0; i--) { img = imgs[i]; imgs[i].setAttribute('src',imgs[i].getAttribute(attribute)); } })(); // 关闭登录弹窗 setTimeout(()=>{ // 获得按钮 closeButton = document.querySelector(".Modal-closeIcon") if(closeButton == null){ return; } // 点击 closeButton.dispatchEvent(new MouseEvent('click', { view: window, bubbles: true, cancelable: true })); // 把html中的“overflow:hidden"去掉,小时滚动条 document.querySelector("html").style.overflow = ""; },1000); // // 展示gif // if (typeof window.orientation == 'undefined') { // // 当前设备不是移动设备,限制gif // // 参考:https://www.ruanyifeng.com/blog/2021/09/detecting-mobile-browser.html // GifPlayers = document.querySelectorAll(".GifPlayer"); // for (var i = GifPlayers.length - 1; i >= 0; i--) { // GifPlayers[i].querySelector(".GifPlayer-cover").style.paddingTop = ''; // GifPlayers[i].getElementsByTagName("video").style.objectFit = "contain" // } // } } // csdn特制 function csdn(){ if('blog.csdn.net' != host){ return; } // 关闭“CSDN:关注博主即可阅读全文” // 参考:https://www.isolves.com/it/cxkf/yy/js/2022-06-29/56707.html var article_content=document.getElementById("article_content"); if(!article_content.hasAttribute('style')){ return; } article_content.removeAttribute("style"); var follow_text=document.getElementsByClassName('follow-text')[0]; follow_text.parentElement.parentElement.removeChild(follow_text.parentElement); var hide_article_box=document.getElementsByClassName('hide-article-box')[0]; hide_article_box.parentElement.removeChild(hide_article_box); } // 腾讯云特制 function tencent_cloud(){ if('cloud.tencent.com'!=host){ return; } var button=document.querySelector("#react-root > div:nth-child(1) > div.J-body.col-body.pg-2-article > div.com-3-layout > div.layout-main > section.com-2-panel.col-2-article.J-articlePanel > div.com-markdown-collpase.com-markdown-collpase-hide > div.com-markdown-collpase-toggle > a"); if(button){ button.click(); } }