// ==UserScript== // @icon https://edu-wenku.bdimg.com/v1/na/0807/%E6%96%87%E5%BA%93APPicon-1603434254133.png // @name 百度文库-精简&优化 // @namespace taozhiyu.gitee.io // @version 0.3.1 // @description 删除主页广告、邀请、垃圾内容 // @author 涛之雨 // @home-url https://greasyfork.org/zh-CN/scripts/422847 // @match *://wenku.baidu.com/* // @grant GM_addStyle // @license GPL-3.0-only // @downloadURL none // ==/UserScript== /**********************************************\ * V 0.3.1 * 修复不能自动展开文章的bug * 添加未登录的逻辑算法 * 新增对于屏蔽登录框配置的保存 * 新增点击【登陆】按钮还原的算法 * V 0.2.2 * 添加GPL-3.0-only协议 * V 0.2.1 * 锁定隐藏首页“邀请好友”banner * 实现免VIP全屏阅读 * 全局滚动条美化 * 修改文库页面的图标 * 重构去除广告代码 * 屏蔽文章末尾的结束提示(因为会遮盖部分界面) * 自动加载全部页面 * 移除主题按钮 * V 0.1.1 * 初版,删除精简大部分垃圾、广告等 * TODO : 实现免VIP全屏阅读 * TODO : 免VIP复制等 \************************************************/ (function() { 'use strict'; const saveInfo=(a)=>{ localStorage.setItem("taozhiyuWKBeautify", JSON.stringify(a)); } const getInfo=()=>{ return JSON.parse(localStorage.getItem("taozhiyuWKBeautify")); } let info=(getInfo()&&Object.keys(getInfo()).length>0)?getInfo():{"noLogin":0} const changeFavicon = link => { let $favicon = document.querySelector('link[rel="shortcut icon"]'); let $favicon1 = document.querySelector('link[rel="icon"]'); $favicon?$favicon.href = link:"" $favicon1?$favicon1.href = link:"" if(!($favicon||$favicon1)){ $favicon = document.createElement("link"); $favicon.rel = "icon"; $favicon.href = link; document.head.appendChild($favicon); } }; //修改logo changeFavicon("https://edu-wenku.bdimg.com/v1/na/0807/%E6%96%87%E5%BA%93APPicon-1603434254133.png"); const killLogin=(iskill=true)=>{ GM_addStyle(` .涛之雨劫持登录style, .pop-mask, .tang-foreground, .left-login, .tang-background, #passport-login-pop{ display:none!important width:0!important; overflow:hidden!important; z-index:-99999!important; }`) if(iskill){ document.querySelector(".user-icon-wrap").onclick=(a)=>{ killLogin(false) } }else{ info.noLogin=0 saveInfo(info) var s=document.getElementsByTagName('style') for(var e=0; e=0){ s[e].remove() } } } } GM_addStyle(` .operate-wrapper, .voucher-pop-tip, .theme-wap, .experience-card-wrap, .convert-btn-point, .try-end-fold-page, .bottom-pop-wrap, .pure-guide-dialog, .vip-card-wrap, .vip-pop-wrap, .inner-vip, .hx-bottom-wrapper, .hx-recom-wrapper, .qr-wrapper, .feedback-wrapper, .hx-right-wrapper.sider-edge, .app-btn, .hx-warp, .client-btn-wrap, .relative-doc-ad-wrapper, .red-point, .tips, .ex-wrapper, .vip-activity-wrap-new, .bz-doc-tool-dialog-fix, .fixed-activity-bar, .doc-tool-dialog-wrapper{ display:none!important; width:0!important; overflow:hidden!important; } .operation-wrapper{ display:none; } .bg-items-wrapper{ margin-left:0!important; } body{ overflow-y: scroll!important; } ::-webkit-scrollbar-track{ -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); border-radius: 10px;background-color: #F5F5F5; } ::-webkit-scrollbar{ width: 8px; background-color: #F5F5F5; } ::-webkit-scrollbar-thumb{ border-radius: 10px; -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3); background-color: #c1c1c1; } `) document.querySelector(".red-dot").classList.remove("red-dot") document.querySelector(".full-screen").classList.add("pure-tool-btn") let a=setInterval(()=>{ let b=document.querySelector(".read-all") if(b){ b.click() clearInterval(a) } },100) setTimeout(()=>{ clearInterval(a) },5000) let b=setInterval(()=>{ if(document.querySelector(".no-login")){ clearInterval(b) if(info.noLogin===0){//0未知 let c=setInterval(()=>{ if(!document.querySelector(".pop-mask,#passport-login-pop")){return} clearInterval(c) if(confirm('是否屏蔽登录窗口?\n本浏览器本网站将一直有效,\n如需[登录]或[清除设置]请\n\n【点击右上角的登陆按钮】')){ info.noLogin=1 saveInfo(info) killLogin() }else{ info.noLogin=2 saveInfo(info) } },100) }else if(info.noLogin===1){//屏蔽 killLogin() } } },100) setTimeout(()=>{ clearInterval(b) },3000) })();