Greasy Fork is available in English.

百度文库去广告

去掉相关文档推荐和购买链接,免开会员使用VIP背景换肤

// ==UserScript==
// @name         百度文库去广告
// @namespace    http://tampermonkey.net/
// @version      0.9.9.4
// @description  去掉相关文档推荐和购买链接,免开会员使用VIP背景换肤
// @author       AN drew
// @match        https://wenku.baidu.com/*
// @match        https://eduai.baidu.com/*
// @require      https://lib.baomitu.com/jquery/3.5.0/jquery.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    GM_addStyle(`html.full-screen::-webkit-scrollbar { width: 0 !important }
html.full-screen { -ms-overflow-style: none; }
html.full-screen { overflow: -moz-scrollbars-none; }
.theme-wrapper{ padding-top: 15px;}
.left-wrapper.zoom-scale{padding:0px}
#right-wrapper-id{display:none!important}
.btn.saveskin {
    height: 36px;
    background: green;
    text-align: center;
    position: absolute;
    right: 60px;
    top: 15px;
    border-radius: 6px;
    font-family: PingFangSC-Medium,sans-serif;
    font-size: 16px;
    color: #fff;
    display: inline-block;
    line-height: 36px;
    vertical-align: middle;
    min-width: 100px;
    cursor: pointer;
}
.btn.saveskin:hover {
    background: #00a900;
}
.btn.close {
    height: 32px;
    width: 32px;
    background: #ff0000ab;
    text-align: center;
    position: absolute;
    right: 18px;
    top: 18px;
    font-family: PingFangSC-Medium,sans-serif;
    font-size: 16px;
    color: #fff;
    display: inline-block;
    line-height: 36px;
    vertical-align: middle;
    cursor: pointer;
    border-radius: 32px;
}
.btn.close:hover {
    background: red;
}
.viewpage .view-body .view-right .right-wrapper{display:none!important}
.header_bg{background:rgb(24,145,226)!important; cursor:auto!important;}
.energy-power{display:none!important}
`);

    if(window.location.href.indexOf("wenku.baidu.com/ndcore/browse/sub") > -1)
    {
        /*
        if(document.querySelector(".red-text.bold-text"))
            document.querySelector(".red-text.bold-text").style.display="none";
        if(document.querySelector(".pay-vip-btn-wrap"))
            document.querySelector(".pay-vip-btn-wrap").style.display="none";
        if(document.querySelector(".sub-right"))
            document.querySelector(".sub-right").style.display="none";
        if(document.querySelector(".sub-main"))
        {
            document.querySelector(".sub-main").style.cssText="display: flex; justify-content: center;";

            document.querySelector(".sub-main").style.display="flex";
            document.querySelector(".sub-main").style.justifyContent="center";
        }
        */
        GM_addStyle(`.red-text.bold-text{display:none!important}
        .pay-vip-btn-wrap{display:none!important}
        .sub-right{display:none!important}
        .sub-main{display: flex; justify-content: center;}`);
    }
    else if(window.location.href.indexOf("wenku.baidu.com/view") > -1)
    {
        if($('.xueshu-logo').length>0)
        {
            GM_addStyle(`.stream-img{display:none!important}`);
        }
        else
        {
            GM_addStyle(`.content-wrapper{display: flex; justify-content: center;}`);
        }
    }

    if (typeof $ != 'undefined')
    {
        if(window.location.href.indexOf('/view/') > -1)
        {
            //清除原默认值
            if($.cookie('mytheme')=='theme-1')
            {
                $.cookie('mytheme', 'classic', { expires: 365, path: "/", domain: "wenku.baidu.com" });
            }

            //设置皮肤
            if($.cookie('mytheme')==undefined)
            {
                $.cookie('mytheme', 'classic', { expires: 365, path: "/", domain: "wenku.baidu.com" });
            }
            else
            {
                $('#app').attr('class',$.cookie('mytheme'));
                $('#app').attr('style',$.cookie('mystyle'));
            }
        }

        //点击换肤按钮后,选择并移动至当前皮肤预览图
        var timer1 = setInterval(()=>{
            if($('.theme-enter-wrap').length>0)
            {
                $('.theme-enter-wrap').click(function(){
                    $('.bottom-theme-select-wrap').show();
                    let myindex = parseInt($.cookie('myindex'));
                    if(isNaN(myindex))
                    {
                        let appImg=$('#app').css('background-image').replace('url("', '').replace('")', '');
                        $('.theme-item .bg-img').each(function(index){
                            let skinImg=$('#app').attr('class',pageData.viewBiz.visitUserInfo.skinInfo.skinList[index].skinImg);
                            if(appImg==skinImg)
                            {
                                myindex=index;
                            }
                        })
                    }
                    setTimeout(()=>{
                        if(!$('.theme-item .bg-img').eq(myindex).hasClass('selected'))
                        {
                            $('.theme-item .bg-img').removeClass('selected');
                            $('.theme-item .bg-img').eq(myindex).addClass('selected');
                        }
                        if(!$('.slide-wrapper').hasClass('slid'))
                        {
                            if(myindex >= 7)
                            {
                                $('.slide-wrapper').attr('style','margin-left: '+(-186*(myindex-7+1))+'px; transition: all 0.3s ease-out 0.1s;')
                            }
                            $('.slide-wrapper').addClass('slid');
                        }
                    },500);
                });
                clearInterval(timer1);
            }
        },1);

        //选择皮肤预览图时
        var timer2 = setInterval(()=>{
            if($('.theme-list').length>0)
            {
                $('.theme-item .bg-img').click(function(){
                    $('.theme-item .bg-img').removeClass('selected');
                    $(this).addClass('selected');
                    let tempindex=$('.theme-item .bg-img').index(this);

                    if(pageData.viewBiz.visitUserInfo.skinInfo.skinList != undefined)
                        $('#app').attr('class',pageData.viewBiz.visitUserInfo.skinInfo.skinList[tempindex].skinId);

                    $.cookie('tempindex', tempindex, { expires: 365, path: "/", domain: "wenku.baidu.com" });
                });
                clearInterval(timer2);
            }
        },1);

        //首次进入自动选择并移动至当前皮肤预览图
        var timer3 = setInterval(()=>{
            if($('.bottom-theme-select-wrap').length>0)
            {
                let myindex = parseInt($.cookie('myindex'));
                if(isNaN(myindex))
                {
                    let appImg=$('#app').css('background-image').replace('url("', '').replace('")', '');
                    $('.theme-item .bg-img').each(function(index){
                        let skinImg=$('#app').attr('class',pageData.viewBiz.visitUserInfo.skinInfo.skinList[index].skinImg);
                        if(appImg==skinImg)
                        {
                            myindex=index;
                            return false;
                        }
                    })
                }
                setTimeout(()=>{
                    if(!$('.theme-item .bg-img').eq(myindex).hasClass('selected'))
                    {
                        $('.theme-item .bg-img').removeClass('selected');
                        $('.theme-item .bg-img').eq(myindex).addClass('selected');
                    }
                    if(!$('.slide-wrapper').hasClass('slid'))
                    {
                        if(myindex >= 7)
                        {
                            $('.slide-wrapper').attr('style','margin-left: '+(-186*(myindex-7+1))+'px; transition: all 0.3s ease-out 0.1s;')
                        }
                        $('.slide-wrapper').addClass('slid');
                    }
                },500);
                clearInterval(timer3);
            }
        },1);

        //保存皮肤
        var $save = $('<div data-v-416af63d="" class="btn saveskin">保存皮肤</div>');

        $save.click(function(){
            if($('#app').attr('class')!=undefined)
            {
                $.cookie('mytheme', $('#app').attr('class'), { expires: 365, path: "/", domain: "wenku.baidu.com" });
                $.cookie('mystyle', $('#app').attr('style'), { expires: 365, path: "/", domain: "wenku.baidu.com" });
            }
            $.cookie('myindex', $.cookie('tempindex'), { expires: 365, path: "/", domain: "wenku.baidu.com" });
            //window.location.reload();
            $('.bottom-theme-select-wrap').hide();
        });

        var $close = $('<div data-v-416af63d="" class="btn close"><svg t="1651740904030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2484" width="30" height="30"><path d="M558.933333 529.066667l285.866667 285.866666-29.866667 29.866667-285.866666-285.866667-285.866667 285.866667-29.866667-29.866667 285.866667-285.866666L213.333333 243.2l29.866667-29.866667 285.866667 285.866667L814.933333 213.333333l29.866667 29.866667-285.866667 285.866667z" fill="#ffffff" p-id="2485"></path></svg></div>');

        $close.click(function(){
            $('.bottom-theme-select-wrap').hide();
        });


        setInterval(()=>{
            if($('.btn.saveskin').length==0)
            {
                $('.theme-list .title-wrap').append($save);
            }
            if($('.btn.close').length==0)
            {
                $('.theme-list .title-wrap').append($close);
            }

            $('.theme-list .btn.join-vip').remove();
            $('.bottom-theme-select-wrap > .btn-close').remove();
            $('div.theme-list div.info').remove();
        },1);


        setInterval(()=>{
            $('body').removeAttr('style');
        },1);

        setTimeout(function(){
            $(".moreBtn.goBtn").click();
            //$(".read-all").click();
            $(".more-coment").click();
            if($(".moreBtn.goBtn").length>0)
            {
                setTimeout(function(){
                    $(window).scrollTop(0);
                },500);
            }
        },1500);

        setInterval(function(){

            $('.ppt-page-item').removeClass('hide');
            $('.relative-doc-newwrapper.sider-edge').hide();
            $('#side-fixed-box').hide();

            $('.woniu-guide-card').hide();
            $('.woniu-tag').hide();
            $('.recommend-aside').hide();
            $('#pc-common-dialog-wrap').hide();
            $('.pc-common-sidebar').hide();

            $('.search-topic-block').height(180);
            $('.specialDisplay-container').height(180);
            $('.specialDisplay-inner').height(180);

            $('.tHiZXQ').hide();
            $('.vip-entrance-bottom').hide();
            $('#top-recommend-dsp-ad').hide();
            $('.search-topic-block').hide();
            $('.tiger-lossUser-dialog-vip').hide();
            $('#go-to-buy-vip-dialog').hide();
            $('.vip-guide-mask').hide();
            $('.new-recommend').hide();
            $('.try-end-fold-page').hide();
            $('.hx-recom-wrapper').hide();
            $('#fengchaoad').hide();
            $('.shop-goods-wrapper').hide();
            $('.opening-season-dialog').hide();
            $('.hx-warp').hide();
            $('.hx-bottom-wrapper').hide();
            $('.bz-doc-tool-dialog-fix').hide();
            $('.fixed-activity-bar').hide();
            $('.dialog-wraper').hide();
            $('.new-skin-wrap').hide();
            $('.pure-guide-dialog').hide();

            $('.vip-activity-wrap-new').hide();
            $('.doc-price-voucher-wrap').hide();
            $('.btn-pay.2').hide();
            $('.btn-pay-vip').hide();
            $('.btn-vip').hide();

            $('.pager-container').hide();
            $('.treasure-main').hide();
            $('.fufei-activity-bar').hide();

            $(".slide-left").hide();
            $(".slide-right").hide();
            $(".bg-items-wrapper").empty();
            $(".bg-items-wrapper").attr("style","width: 700%; margin-left: -100%; background: linear-gradient(rgb(65, 210, 93), rgb(32, 181, 122));")
            $(".slide-circle-wrapper").hide();
            $(".promotion-wrapper").hide();
            $(".doc-pack-wrapper").hide();
            $("#book-rec-wrapper").hide();
            $("#app > div.header-wrapper > div.search-wrapper > div.hot-words-wrapper > div.hot-words-items > div:nth-child(2)").hide();

            $(".aside-rknow-con").hide();
            $(".zsj-topbar.mini").hide();
            $(".search-nav").removeClass("zsj-act");
            $(".bd-wrap").removeClass("zsj-act");
            $(".search-aside-adWrap").hide();
            $(".yuedu-recommend-wrap").hide();
            $(".header-box-recommend.clearfix.inline").hide();
            $(".search-wrapper-box-recommend.clearfix").hide();
            $(".footer-box-recommend.clearfix").hide();
            $(".summary-recommend.clearfix.has-content").hide();
            $(".open-vip-button ").hide();

            $('.confirm-change').hide();
            $('.btn.super-vip').hide();
            $('.slogan+.btn').hide();
            $('.specific-user-dialog-wrap').hide();
            $('.experience-card-old-dialog-wrap').hide();
            $("table tr:first").hide();
            $("#banurl").hide();
            $(".mn-lk-w.member-icon").next().hide();
            $("#hd > div > div.nav-wrap.mb10 > div > div > ul.main-nav.side-nav.clearfix > li:nth-child(1)").hide();
            $(".top-ads-banner-wrap").hide();
            $(".zsj-toppos").hide();
            $(".ui-bz-hot-ic").hide();
            $(".qua-box").hide();
            $("#__elm_view-like-recom__qk_1").hide();
            $("#__elm_view-like-recom__qk_2").hide();
            $("#__elm_view-like-recom__qk_3").hide();
            $(".ft").hide();
            $("#next_doc_box").hide();
            $(".convert-tip").hide();
            $(".toolbar-core-btns-wrap").find(".btn-pay-vip").hide();
            $("#relative-doc-item").hide();
            $(".welfare-pop-tip").hide();
            $(".wangpan-tip").hide();
            $(".lastcell-dialog").hide();
            $(".service-entry").hide();
            $(".ad-area").hide();
            $(".banner-ad.banner-wrap.ad-onff").hide();
            $(".wkfc-wrap.ad-onff").hide();
            $(".banner-ad").hide();

            $(".edit-subscription-dialog-wrapper.mod").hide()
            $(".hot-option-word-wrapper").hide()
            $(".tangram-suggestion-main").hide();

            $(".CASH_PACK-CASH.summary").hide();
            $(".CASH_PACK-CASH.searchBox").hide();
            $(".CASH_PACK-CASH.topBar").hide();

            $(".CASH_DISCOUNT-CASH.summary").hide();
            $(".CASH_DISCOUNT-CASH.searchBox").hide();
            $(".CASH_DISCOUNT-CASH.topBar").hide();

            $(".CASH_DISCOUNT-VIP_RIGHT.summary").hide();
            $(".CASH_DISCOUNT-VIP_RIGHT.searchBox").hide();
            $(".CASH_DISCOUNT-VIP_RIGHT.topBar").hide();

            $(".-VIP_RIGHT.summary").hide();
            $(".-VIP_RIGHT.searchBox").hide();
            $(".-VIP_RIGHT.topBar").hide();

            $('.slogan').hide();
            $(".red-text").hide();
            $(".operate-wrapper").hide();
            $(".bottom-pop-wrap").hide();
            $(".pay-layer1509-wrapper").hide();
            $(".pay-vip-btn-wrap").hide();
            $(".relative-search-wrap").hide();
            $(".relative-recommend-wrapper").hide();
            $(".operation-wrapper").hide();
            $(".relative-doc-wrapper").hide();
            $(".relative-course-wrapper").hide();
            $(".hot-search-wrapper").hide();
            $(".hx-right-wrapper").hide();
            $(".doc-voucher-wrap").hide();
            $(".core-btn-wrapper.CASH_DISCOUNT-CASH.CASH_DISCOUNT.summary.t1272-0.nafe-1509").hide();
            $(".core-btn-wrapper.CASH_DISCOUNT-CASH.CASH_DISCOUNT.searchBox.t1272-0.nafe-1509").hide();

            $(".voucher-center-wrap").hide();
            $("#add-price-buy-wrap").hide();
            $(".recommend-wrap.clearfix.notjigou").hide();
            $(".searchMode01").parent().parent().parent().hide();

            $(".right-channel-wrap").hide();
            $(".ex-wrapper").hide();
            $(".query-sug").hide();

            $('#app-left').hide();
            $('#app-right').hide();
            $('.fc-result-container').hide()
            $('.catalog-main').hide();

            $('.experience-card-dialog-wrap, .experience-card-bar-wrap').hide();
        },1);
    }

    setInterval(function(){
        $('.header_bg').off();
        $('.num').remove();
    },100);

})();