Greasy Fork

Greasy Fork is available in English.

百度文库-精简&优化

删除主页广告、邀请、垃圾内容

当前为 2021-05-04 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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.11
// @description  删除主页广告、邀请、垃圾内容
// @author       涛之雨
// @home-url	 http://greasyfork.icu/zh-CN/scripts/422847
// @match        *://wenku.baidu.com/*
// @grant	     GM_addStyle
// @license      GPL-3.0-only
// @run-at       document-start
// ==/UserScript==
/**********************************************\
 * V 0.3.11
 * 新增对于【工具箱】引导的拦截
 * V 0.3.10
 * 添加对新版开屏弹窗的支持
 * V 0.3.9
 * 修复新弹窗未屏蔽的bug
 * V 0.3.8
 * 修复新弹窗未屏蔽的bug
 * 修复部分页面广告、logo未删除的bug,等
 * V 0.3.7
 * 移除文件页的水印
 * 对文库搜索页添加适配
 * 首页banner广告改为固定图片
 * 移除首页bd恰饭内容(推荐,限时降价,VIP推荐等)
 * 修改脚本运行的时机,以减少延时感
 * V 0.3.6
 * 因仅word支持背景色,暂时移除
 * V 0.3.5
 * 添加背景色
 * V 0.3.4
 * 删除文章尾部版权说明
 * V 0.3.3
 * 版本号错乱,强制升级
 * V 0.3.2
 * 修复按钮判断逻辑错误!
 * 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)=>{
        if(iskill){
            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;
}`);
            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<s.length;e++){
                if(s[e].innerHTML.indexOf("涛之雨劫持登录style")>=0){
                    s[e].remove();
                }
            }
        }
    };
//.vip-layer-inner,
//.pay-layer1509-wrapper,
// [class*=pay-]{
// display:none!important;
// width:0!important;
// overflow:hidden!important;
// }
    GM_addStyle(`.copyright-wrap,
.user-guide-mask,
.opening-season-dialog,
[class*=pay-],
.vip-wrapper,
.client-wrapper,
.privilege-merging-dialog-wrap,
.notice-info-wrap,
.dialog-wraper,
.active-dialog-wrapper,
.client-download-wrap,
.product,
.red-text.bold-text,
#fengchaoad,
.tousu,
.new-vip-card-position,
.top-recommend-dsp-ad,
.woniu-wrap,
.topicBox,
.search-topicBox-wrap,
.author-organizition-wrapper,
.search-aside-adWrap,
#mywenku,
.doc-pack-wrapper,
.vip-content-wrapper,
.promotion-wrapper,
.user-card-wrapper,
.slide-wrapper,
.bg-wrapper,
.slide-circle-wrapper,
.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,
.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,
.hx-warp,
.operation-wrapper,
.reader-page > div:nth-last-child(1),
.ppt-page-item > div:nth-last-child(1),
.doc-tool-dialog-wrapper{
display:none!important;
width:0!important;
overflow:hidden!important;
}
/*:last-of-type:nth-last-child(1)*/

.header-wrapper{
background-repeat: no-repeat;
background-position: 50% 0;
background-size: cover;
height: 100%;
background-image: url(https://edu-wenku.bdimg.com/v1/pc/2020%E4%BA%8C%E7%BA%A7%E9%A1%B5/%E5%AD%A6%E5%89%8D%E6%95%99%E8%82%B2-1584342432680.png)!important;
}
.product-line-wrap{
float: left;
padding-left: 22px;
}

.red-dot,.red-dot:after{
background-color:unset!important;
}
.small-btn-wrap{
float:unset!important;
}
.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;
height: 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;
}
`);
    let a=setInterval(()=>{
        let b=document.querySelector(".read-all")
        if(b){
            b.click();
            clearInterval(a);
        }
    },100);
    setTimeout(()=>{
        clearInterval(a);
        document.querySelector(".full-screen")&&document.querySelector(".full-screen").classList.add("pure-tool-btn");
    },3000);
    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);
        (()=>{
            let d=document.querySelector(".small-btn-wrap");
            if(d){
            const a=document.createElement("span");
            a.innerHTML="【涛之雨】美化插件";
            a.style='color: #666;font-size: 14px;font-family: PingFangSC-Regular;';
            d.append(a);
            }
        })();
    },3000);
    /*护眼色 > div
#reader-container{
background-color: rgb(199 237 204);
}*/
})();