Greasy Fork

Greasy Fork is available in English.

百度云精简

删除“复制这段内容后打开百度网盘手机App,操作更方便哦,来自百度会员超级无敌永久svip”,精简部主页广告、邀请,视频添加倍速按钮

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @icon         https://pan.baidu.com/m-static/base/static/images/favicon.ico
// @name         百度云精简
// @namespace    taozhiyu.gitee.io
// @version      0.3.4
// @description  删除“复制这段内容后打开百度网盘手机App,操作更方便哦,来自百度会员超级无敌永久svip”,精简部主页广告、邀请,视频添加倍速按钮
// @author       涛之雨
// @require      https://cdn.bootcdn.net/ajax/libs/clipboard.js/2.0.6/clipboard.min.js
// @match        *://pan.baidu.com/disk/*
// @match        *://pan.baidu.com/mbox/*
// @match        *://pan.baidu.com/play/*
// @match        *://yun.baidu.com/disk/*
// @match        *://yun.baidu.com/mbox/*
// @match        *://yun.baidu.com/play/*
// @match        *://pan.baidu.com/s/*
// @match        *://yun.baidu.com/s/*
// @match        *://pan.baidu.com/share/*
// @match        *://yun.baidu.com/share/*
// @grant	     GM_addStyle
// @grant	     unsafeWindow
// @grant        GM_getValue
// @grant        GM_setValue
// @home-url	 http://greasyfork.icu/zh-CN/scripts/422814
// @license      GPL-3.0-only
// ==/UserScript==
/**********************************************\
 * 移除小尾巴部分修改自http://greasyfork.icu/zh-CN/scripts/374100
 * 自定义密码部分修改自http://greasyfork.icu/zh-CN/scripts/423146
 * V 0.3.4
 * 悄咪咪修复部分(感觉就只有大萝卜一个)人百度网盘LOGO显示异常的问题(换了个图标)
 * 修复百度云更新造成的脚本无法倍速播放视频(目前仅有百度云VIP方可使用。。。)
 * 修复速率调节快捷键的一个bug(目前仅有百度云VIP方可使用。。。)
 * 添加“画中画”功能(需要浏览器支持),画中画模式快捷键将会失效,全屏自动退出画中画模式
 * V 0.3.3
 * 植入自定义密码功能(修改自【http://greasyfork.icu/zh-CN/scripts/423146】,感谢提供思路,已获得授权)
 * 优化上述脚本
 * 修改默认分享时间为【永久】
 * 新增对于“内测提醒”弹窗的关闭支持
 * 倍速貌似失效了?算了,有空再看吧
 * V 0.3.2
 * 紧急修复误伤压缩包查看的bug
 * V 0.3.1
 * 新增对于【压缩包】、【CAD】和【思维导图】文件打开引导的屏蔽。
 * 新增在播放界面,新增快捷键控制播放速度:
 * -- (shift键无论是否按下,)按数字【0】即可恢复正常速度(原速快捷键)
 * -- 按下数字【1-9】可以分别调整速度为【1.25,1.5,1.75,2,2.4,2.7,4,6,8】(倍速快捷键)
 * -- 按下【shift】后再按下数字【1-9】可以分别调整速度为【0.1,0.15,0.2,0.25,0.3,0.5,0.6,0.8,0.9】(慢速快捷键)
 * -- (shift键无论是否按下,)每次按下【-】,当前速率减小0.1
 * -- (shift键无论是否按下,)每次按下【=】,当前速率增加0.1
 * V 0.3.0
 * 添加 + 自动读取、提交提取码的功能(第一次运行需要授权,有引导界面)
 * V 0.2.9
 * 修复 + 因为图省事,通用匹配导致某些界面被屏蔽的bug
 * V 0.2.8
 * 修复 + 视频倍速播放自动恢复的暗装(涛之雨全网独家的方法,如有借鉴请说明出处)
 * V 0.2.7
 * 调整 + 转存后的布局
 * 修复 + 删除部分遗漏广告
 * 新增 + 对于文件分享界面,的去广告支持
 * V 0.2.6
 * 新增 + 对于分享页的适配(去广告)
 * 新增 + 视频播放页添加倍速按钮(仿原生,贼强)
 * 添加 + 遵循协议 GPL-3.0-only
 * TODO : 默认永久分享(可自定义1-365天和永久)
 * TODO : 自定义分享密码(或公开链接,无密码)
 * TODO : 自定义限制分享次数链接
 * V 0.2.5
 * 新增 + 对于“在线视频”界面的支持
 * TODO : 加上倍速播放按钮
 * V 0.2.4
 * 新增 + 对于“分享”界面的支持
 * V 0.2.3
 * 删除 - 百度文库相关代码,迁移到新项目
 * V 0.2.1
 * 新增 + 百度文库大量垃圾、广告删除
 * TODO : 正在研究非VIP会员免【广告全屏阅读】
 * V 0.1.7
 * 修复 + “个人分享”界面“复制这段内容...”移除失败的bug
 * 新增 + 删除主界面的部分垃圾(可以自行对比)
 * 新增 + 关闭4秒内主动弹出的【设备管理】、【新功能测试】、【在线文档】、【在线解压】、等等。。。窗口
\************************************************/
(function() {
    'use strict';
    const w=unsafeWindow||window;
    let myvideojs;
    var $ = $ || window.$ || w.$;
    const saveInfo=(a)=>{
        GM_setValue("BaiduYunBeautify", JSON.stringify(a));
    };
    //兼容之前的版本,迁移数据并移除
    const getInfo=()=>{
        return JSON.parse(localStorage.getItem("taozhiyuPanConfig"));
    };
    let oldinfo=(getInfo()&&!!getInfo().isfrist)?getInfo().isfrist:true;
    localStorage.clear("taozhiyuPanConfig");
    let info=GM_getValue("BaiduYunBeautify")?JSON.parse(GM_getValue("BaiduYunBeautify")):{};
    if(Object.keys(info).length<3){
        !info.SetKey&&(info.SetKey=true);
        !info.sharePwd&&(info.sharePwd="");
        !info.isFristAutoEnterKey&&(info.isFristAutoEnterKey=oldinfo);
        saveInfo(info)
    }
    GM_addStyle(`.phone-banner,
.button-badge,
.hx-right-bottom,
.title-wrap > .join-vip,
.title-wrap > .info,
.hx-bottom-wrapper,
.hx-recom-wrapper,
.app-btn,.hx-warp,
.relative-doc-ad-wrapper,
.qr-wrapper,
.cert-tip,
.side-doc-tool-wrapper,
.feedback-wrapper,
.popover-container,
.privilege-box,
.vip-pop-wrap,
.red-point,
.wp-side-options,
.module-header-wrapper > dl > dd[node-type='header-union'],
.yike-entrance,
.find-light-icon,
.newIcon,
.app-download,
.app-notice,
.icon-notice,
.icon-feedback,
.app-feedback,
.wp-disk-header__right-item,
.bz-doc-tool-dialog-fix,
.ex-wrapper,
.fixed-activity-bar,
.vip-card-wrap,
.btn-img-tips,
.rights-section,
a[title="举报"],
div[class^="ad-"],
.share-file__link-ad,
.vip-activity-content,
.video-title-right-open-mobile,
.tips{
display:none!important;
width:0!important;
overflow:hidden!important;
}

.after-trans-dialog .info-section {
    padding-top: 99px!important;
}

#SetKey{
display: inline-block;
color: #fff;
font-size: 16px;
height: 42px;
line-height: 38px;
margin: 0 25px;
vertical-align: middle;
position: relative;
padding: 0 2px;
cursor: pointer;
}

#SetKey:hover {
    opacity: .8;
}

.video-js .vjs-playback-rate{
	line-height: 2em;
    font-size: 1.4em;
}
.vjs-workinghover .vjs-menu-button-popup:hover .vjs-menu{
	margin-bottom: 0.67em!important;
}
`);
    let t = " ", e = "text", o = "去除小尾巴失败o(╥﹏╥)o", a = "body", l = "copy",y=true,f=(a)=>{a.style.display="none";a.style.width=0;a.style.overflow="hidden"};
    document.querySelector(a).addEventListener(l, function(a) {try {let l = a.target.value;l = l.split(t).filter((t, e) => {if(!!t.match(/手机App|复制这段/))y=false;return y}).join("").replace("提取码"," 提取码"),a.clipboardData.setData(e, l),a.preventDefault(),y=true; } catch (a) { console.log(o);}});
    function autoInputCode(callback){
        navigator.clipboard.readText().then(a =>{
            callback(true,a)
        }) .catch((v) => {
            callback(false,v)
        });
    }

    if(location.href.indexOf("/share/my")<0){
        $(document).on("DOMNodeInserted", ".share-file__link-expired", function() {
            if ($(".nd-input-share-pwd").length == 0) {
                setTimeout(()=>{
                    var o=document.querySelector("#g-select-1");
                    o.querySelector(".g-select-inner").click()
                    var event = new CustomEvent("mousedown",{bubbles: 'true'});
                    o.querySelector('#g-select-1 [data-value="0"]').dispatchEvent(event);
                },200);
                var html = '<div style="margin:10px;"></div><div class="share-file__link-expired-title">自定义分享密码</div>';
                html += '<div class="share-file__link-pwd"><div class="share-file__link-pwd-label">提取码</div>';
                html += '<input type="text" class="nd-input-share-pwd" value="' + (info.sharePwd ? info.sharePwd : "") + '" placeholder="为空则随机四位" style="margin-left: 16px; width: 120px; height: 32px; line-height: 28px; border: 1px solid #D4D7DE; border-radius: 8px; text-align: left; padding-left: 12px"></div>';
                $(".share-file__link-expired").after(html);
            }
        });

        w.require.async("function-widget-1:share/util/newShare/linkSetting.js", function (a) {
            a.a = a.makePrivatePassword;
            a.makePrivatePassword = function () {
                return info.sharePwd ? info.sharePwd : this.a();
            };
        });

        $(document).on("change", ".nd-input-share-pwd", function () {
            var value = this.value;
            if (value && !/[^\W_]{4}/.test(value)) {
                w.require("system-core:system/uiService/tip/tip.js").show({mode: "failure", msg: "提取码不合规范,只能是四位字母数字组合"});
            }else{
                info.sharePwd=value;
                saveInfo(info);
            }
        });
    }
    if(location.href.indexOf("baidu.com/disk/")>=0){
        let id=setInterval(()=>{
            document.querySelectorAll(".pdf2word-tip-close-btn").forEach(a=>{a.click()});
            document.querySelectorAll(".dialog-close").forEach(a=>{a.click()});
            document.querySelectorAll(".close-mask").forEach(a=>{a.click()});
            document.querySelectorAll(".common-dialog-close").forEach(a=>{a.click()});
            document.querySelectorAll(".wp-guide-dialog-close").forEach(a=>{a.click()});
            document.querySelectorAll(".wp-tip-close-btn").forEach(a=>{a.click()});
            document.querySelectorAll(".guide-dialog-close").forEach(a=>{a.click()});
            document.querySelectorAll(".wp-disk-header__right-item").forEach((a)=>{if(a.href&&!!a.href.match(/buy|addnew/)){f(a);}});
        },1);
        setTimeout(()=>{clearInterval(id)},5000)
        window.addEventListener("mouseup",a=>{
            if(a.target.title!=="分享"){return;}
            let id2=setInterval(()=>{
                const x=document.querySelectorAll(".share-file__link-ad");
                if(!x){return;}
                x.forEach((a)=>{f(a);});
                setTimeout(()=>{clearInterval(id2)},100);
            },10);
        });
    }else if(location.href.indexOf("play/video")>=0){
        const getmyvideo=a=>{
            if(!myvideojs)return false;
            if(!myvideojs.players){
                try{
                    if(!!myvideojs(a))return myvideojs(a);else return false;
                }catch(e){return false;}
            }else{
                if(!!myvideojs.players[a])return myvideojs.players[a];else return false;
            }
        }
        let id=setInterval(()=>{
            myvideojs=myvideojs||w.videoPlayer;
            if(myvideojs&&!!getmyvideo("html5player")){
                clearInterval(id);
                if(document.pictureInPictureEnabled){
                    GM_addStyle(`
.video-functions-tips{
margin-top: -26px;
}
`);
                    getmyvideo("html5player").tech_.el_.disablePictureInPicture=false;
                    let li=document.createElement("li");
                    li.id="PInP_tao";
                    li.innerHTML='<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1168" style="width: 26px;height: 24px;margin-top: -7px;"><path d="M782 273H242v478h179v0.31a40.338 40.338 0 0 1 4.339-0.305L426 751c22.091 0 40 17.909 40 40s-17.909 40-40 40c-1.693 0-3.362-0.105-5-0.31v0.31H222c-33.137 0-60-26.863-60-60V253c0-33.137 26.863-60 60-60h580c33.137 0 60 26.863 60 60v176c0 22.091-17.909 40-40 40s-40-17.909-40-40V273z m20 263c33.137 0 60 26.863 60 60v175c0 33.137-26.863 60-60 60H588c-33.137 0-60-26.863-60-60V596c0-33.137 26.863-60 60-60h214z m-20 80H608v135h174V616z" p-id="1169" fill="#ffffff"></path></svg><span style="margin-top: -4px;">画中画</span>';
                    document.querySelector("ul.tips-ul.three-items").append(li)
                    document.querySelector("#PInP_tao").onclick=()=>{
                        var Observer;
                        if (!document.pictureInPictureElement) {
                            Observer= new MutationObserver(function (mutations, instance) {
                                if (document.pictureInPictureElement) {
                                    if(getmyvideo("html5player").el_.classList.value.indexOf("vjs-fullscreen")>=0){
                                        //                                         console.log("进入全屏,关闭画中画");
                                        document.exitPictureInPicture().catch(e => console.warn("不会吧不会吧,开启没失败,取消反而失败了?",e));
                                        Observer&&(Observer.disconnect(),Observer=undefined);
                                    }
                                }else Observer&&(Observer.disconnect(),Observer=undefined);
                            });

                            Observer.observe(getmyvideo("html5player").el_, {
                                attributes: true,
                                attributeFilter: ["class"]
                            });
                            getmyvideo("html5player").tech_.el_.requestPictureInPicture().catch(e=>console.warn("画中画开启失败:",e));
                        }else{
                            document.exitPictureInPicture()
                                .catch(e => console.warn("不会吧不会吧,开启没失败,取消反而失败了?",e));
                            Observer&&(Observer.disconnect(),Observer=undefined);
                        }
                    }
                }else console.log("很遗憾,不支持画中画功能");
                if(!document.querySelector(".level-2,.level-1"))return;//非会员(暂时)不配
                let ne=()=>myvideojs.getComponent("Spacer").prototype.createEl(...arguments),
                    Jn=myvideojs.getComponent("Menu"),
                    gr=myvideojs.getComponent("PlaybackRateMenuItem");
                function a(a,b){a.prototype=Object.create(b.prototype);a.prototype.constructor=a;a.__proto__=b;};var vr=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).updateVisibility(),i.updateLabel(),i.on(e,"loadstart",i.updateVisibility),i.on(e,"ratechange",i.updateLabel),i}a(e,n);var t=e.prototype;return t.createEl=function(){var e=n.prototype.createEl.call(this);return this.labelEl_=ne("div",{className:"vjs-playback-rate-value",innerHTML:"1x"}),e.appendChild(this.labelEl_),e},t.dispose=function(){this.labelEl_=null,n.prototype.dispose.call(this)},t.buildCSSClass=function(){return"vjs-playback-rate "+n.prototype.buildCSSClass.call(this)},t.buildWrapperCSSClass=function(){return"vjs-playback-rate "+n.prototype.buildWrapperCSSClass.call(this)},t.createMenu=function(){var e=new Jn(this.player()),t=this.playbackRates();if(t)for(var i=t.length-1;0<=i;i--)e.addChild(new gr(this.player(),{rate:t[i]+"x"}));return e},t.updateARIAAttributes=function(){this.el().setAttribute("aria-valuenow",this.player().playbackRate())},t.handleClick=function(e){for(var t=this.player().playbackRate(),i=this.playbackRates(),n=i[0],r=0;r<i.length;r++)if(i[r]>t){n=i[r];break}this.player().playbackRate(n)},t.playbackRates=function(){return this.options_.playbackRates||this.options_.playerOptions&&this.options_.playerOptions.playbackRates},t.playbackRateSupported=function(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&0<this.playbackRates().length},t.updateVisibility=function(e){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")},t.updateLabel=function(e){this.playbackRateSupported()&&(this.labelEl_.innerHTML=this.player().playbackRate()+"x")},e}(myvideojs.getComponent('MenuButton'));vr.prototype.controlText_="Playback Rate";
                //             w.videojs=videojs;
                //                 if(!myvideojs.players.html5player.controlBar.childNameIndex_.playbackRateMenu||!document.querySelector(".level-2,.level-1")){//没有倍速按钮的填上&&会员不用替换了
                myvideojs.registerComponent("PlaybackRateMenuButton",vr);
                const Myplayback=myvideojs.extend(myvideojs.getComponent('PlaybackRateMenuButton'), {//PlaybackRateMenuButton
                    handleClick: function() {
                        if(this.menu.el_.style.display === '' || this.menu.el_.style.display === 'none'){
                            this.menu.el_.style.display = 'block';
                        }else{
                            this.menu.el_.style.display = 'none';
                        }
                    },
                    playbackRates: function() {
                        return [0.5,1,1.5,2,2.7,4];
                    },
                    controlText_:" 播放速率,\n涛之雨解锁VIP"
                });
                myvideojs.registerComponent('Myplayback', Myplayback);
                myvideojs.players.html5player.controlBar.addChild('Myplayback', {}, 6);
                myvideojs.players.html5player.controlBar.removeChild('playbackRateMenu');
                //                     if(!document.querySelector(".level-2,.level-1")){//会员不用等待广告
                //                         setTimeout(()=>{
                //                             var aid=setInterval(()=>{
                //                                 if(myvideojs.players["html5-werbung-player"].el_.classList.value.indexOf("vjs-paused")>=0){
                //                                     clearInterval(aid);
                //                                     for(let k=0;k<99999;k++)clearTimeout(k);//移除锁定
                //                                     for(let k=0;k<99999;k++)clearTimeout(k);//移除锁定
                //                                     for(let k=0;k<99999;k++)clearTimeout(k);//移除锁定
                //                                 }
                //                             },500);
                //                         },2000);
                //                     }else{
                for(let k=0;k<99999;k++)clearTimeout(k);//移除锁定
                for(let k=0;k<99999;k++)clearTimeout(k);//移除锁定
                for(let k=0;k<99999;k++)clearTimeout(k);//移除锁定
                //                     }
                //                 }
                var SetKey=document.createElement("sapn");
                SetKey.id="SetKey";
                SetKey.innerHTML="快捷键已"+(info.SetKey===true?"打开【√】":"关闭【×】");
                SetKey.title=` * 在播放界面,新增快捷键控制播放速度:
 * (shift键无论是否按下,)按数字【0】即可恢复正常速度(原速快捷键)
 * 按下数字【1-9】可以分别调整速度为【1.25,1.5,1.75,2,2.4,2.7,4,6,8】(倍速快捷键)
 * 按下【shift】后再按下数字【1-9】可以分别调整速度为【0.1,0.15,0.2,0.25,0.3,0.5,0.6,0.8,0.9】(慢速快捷键)
 * (shift键无论是否按下,)每次按下【-】,当前速率减小0.1
 * (shift键无论是否按下,)每次按下【=】,当前速率增加0.1`;
                document.querySelector('dd[node-type="header-link"]').append(SetKey);
                document.querySelector("#SetKey").onclick=(a)=>{
                    info.SetKey=!info.SetKey;
                    a.target.innerHTML="快捷键已"+(info.SetKey===true?"打开【√】":"关闭【×】");
                    saveInfo(info);
                }
                var safeTime=false;
                document.onkeydown=function(e){
                    if(safeTime||!info.SetKey)return;
                    safeTime=true;
                    var k=e.keyCode || e.which || e.charCode;
                    var p=myvideojs.getPlayers("video-player").html5player.tech_.playbackRate();
                    if(k===48)p=1;
                    else if(k>=49&&k<=57)p=(!e.shiftKey?[1.25,1.5,1.75,2,2.4,2.7,4,6,8]:[0.1,0.15,0.2,0.25,0.3,0.5,0.6,0.8,0.9])[k-49];
                    else if(k===189)p-=0.1;
                    else if(k===187)p+=0.1;
                    myvideojs.getPlayers("video-player").html5player.tech_.setPlaybackRate(parseFloat(p.toFixed(2)));
                    setTimeout(()=>{safeTime=false},50);
                }
            }
        },500);
        //setTimeout(()=>{clearInterval(id)},10000)
    }else if(location.href.indexOf("share/init")>=0){
        if(info.isFristAutoEnterKey){
            info.isFristAutoEnterKey=false;
            saveInfo(info);
            var m=document.createElement("div");
            m.style="position: fixed;left: 0px;top: 0px;z-index: 50;background: rgb(0, 0, 0);opacity: 0.7;font-size: 30px;width: 100%;line-height: 2;display: flex;height: 100%;align-items: center;justify-content: center;flex-direction: column;color: wheat;flex-wrap: wrap;";
            m.id="taozhiyuMask";
            m.innerHTML='<p>为了便于自动获取提取码</p><p>请在弹出框内点击允许</p><p>否则仅能手动输入/粘贴</p><br><p style="font-size: 14px;line-height: 1;">该信息仅在第一次打开时出现,点击屏幕消失</p>';
            document.querySelector("body").append(m);
            m.onclick=()=>{
                m.remove();
            };
        }
        navigator.permissions.query({name: "clipboard-read"}).then(result => {
            if (result.state == "granted" || result.state == "prompt") {
                autoInputCode( (c,a)=>{
                    if(c){
                        let b=a.match(/(?:密|提取|访问|訪問)[碼码]?\s*[::]?\s*([a-z\d]{4})/);
                        if(!!b){
                            console.log("匹配到密码:",b[1]);
                            document.querySelector("#accessCode").value=b[1];
                            document.querySelector("#submitBtn").click()
                        }else{
                            console.log("未匹配到常见密码")
                        }
                    }else{
                        console.log("不让我读取剪贴板你就自己粘贴去\n\n╭(╯^╰)╮哼\n\n如果是误操作请到“chrome://settings/content/clipboard”允许脚本读取剪贴板");
                    }
                })
            }else{
                console.log("不让我读取剪贴板你就自己粘贴去\n\n╭(╯^╰)╮哼\n\n如果是误操作请到“chrome://settings/content/clipboard”允许脚本读取剪贴板");
            }
        })
    }
})();