bilibili 旧播放页

切换旧版播放页面,布局、播放器全部切换回2019年12月09日之前的样子。

Version au 30/12/2019. Voir la dernière version.

Vous devrez installer une extension telle que Tampermonkey, Greasemonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Userscripts pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension de gestionnaire de script utilisateur pour installer ce script.

(J'ai déjà un gestionnaire de scripts utilisateur, laissez-moi l'installer !)

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

(J'ai déjà un gestionnaire de style utilisateur, laissez-moi l'installer!)

// ==UserScript==
// @name         bilibili 旧播放页
// @namespace    Motoori Kashin
// @version      2.1.1
// @description  切换旧版播放页面,布局、播放器全部切换回2019年12月09日之前的样子。
// @author       Motoori Kashin
// @match        *://*.bilibili.com/video/av*
// @match        *://*.bilibili.com/watchlater/*
// @license      MIT
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    //window.stop();/*阻止原页面继续加载,但配合`@run-at document-start`可能会导致无法替换失败*/
    //document.open();document.write('<!DOCTYPE html><html><head></head><body><div>loading</div></body></html>');document.close();/*覆盖原网页延迟加载元素,已用同步请求解决,不够再打开*/
    if(location.pathname.startsWith('/video')) {
        const xhr = new XMLHttpRequest();
        xhr.open('GET', window.location.href, false);
        xhr.send(null);
        if (xhr.status === 200) {
            const OHTML = xhr.responseText;/*获取原始数据供旧播放页使用*/
            wrVideo(OHTML);
        }
    }
    else{
        const xhr = new XMLHttpRequest();/*缓解稍后再看切换失败的问题*/
        xhr.open('GET', window.location.href, false);
        xhr.send(null);
        if (xhr.status === 200) {
            const OHTML = xhr.responseText;
            wrWatchlater(OHTML);
        }
    }
    var cdm = setInterval(function(){/*自动切换到弹幕列表*/
        var dmlist = document.getElementsByClassName("bilibili-player-filter-btn")[1];
        if (dmlist){
            dmlist.click();
            clearInterval(cdm);
        }
    }, 1000);
    function wrVideo(oht){
        var html = oht;
        var wrh = html.match(/<script type="text\/javascript">window.__BILI_CONFIG__.+?<\/script>.+?<\/script>.+?<\/script>/);
        html = html.replace(/<script\b[\s\S]*?<\/script>/g,"");
        var a = html.replace(/<style\b[\s\S]*?<\/style>/g,"");
        a = a.replace(/<link\b[\s\S]*?>/g,"");
        html = a.replace(/<body\b[\s\S]*?<\/body>/g,"<body>xxx</body>");
        wrh = wrh + '<!--主样式表,后面根据稍后再看页面主样式表补充修复了部分内容--><link rel="stylesheet" href="//s1.hdslb.com/bfs/static/jinkela/videoplay/css/video.1.b1b7706abd590dd295794f540f7669a5d8d978b3.css"><style>#bofqi .player {width:980px;height:556px;display:block;}.pop-live{height:162px}</style></head>';
        html = html.replace(/<\/head>/g,wrh);
        var wrb = reBody();
        html = html.replace(/xxx/g,wrb);
        document.open();
        document.write(html);
        document.close();
    }
    function reBody(){
        var wrb = '<script type="text/javascript" src="https://static.hdslb.com/js/jquery.min.js"></script>' +
            '<!--主框架,由脚本自动填充渲染不需要管它而且里面不能有东西--><div id="app" data-server-rendered="true"></div>' +
            '<!--播放器框架,这个东西本来在app里面的,但是如果放在里面脚本填充网页会销毁掉……放在外面加载完它会自己跑进去……--><div class="bili-wrapper" id="bofqi"></div>' +
            '<div class="footer bili-footer"></div>' +
            '<script type="text/javascript" src="https://static.hdslb.com/js/video.min.js"></script>' +
            '<script type="text/javascript">window.getInternetExplorerVersion=function(){var rv=-1;if(navigator.appName=="Microsoft Internet Explorer"){var ua=navigator.userAgent;var re=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");if(re.exec(ua)!=null){rv=parseFloat(RegExp.$1)}}return rv};function getQueryString(name){var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)");var r=window.location.search.substr(1).match(reg);if(r!=null){return unescape(r[2])}return null}var vd=window.__INITIAL_STATE__&&window.__INITIAL_STATE__.videoData;if(vd&&vd.aid&&getInternetExplorerVersion()!==9){$("#__bofqi").innerHTML=' + "'" + '<div class="bili-wrapper" id="bofqi"><div id="player_placeholder"></div></div>' + "'" + ';if(vd.embedPlayer){var p=getQueryString("p")?getQueryString("p")-1:0;var player={aid:vd.aid,cid:(vd.pages[p]&&vd.pages[p].cid)||vd.pages[0].cid};EmbedPlayer("player","https://static.hdslb.com/play.swf","cid="+player.cid+"&aid="+player.aid+"&pre_ad=")}if(vd.embed){$("#bofqi").html(vd.embed)}}else{$("#bofqi").remove()};</script>' +
            '<script src="//s1.hdslb.com/bfs/static/jinkela/videoplay/manifest.b1b7706abd590dd295794f540f7669a5d8d978b3.js" crossorigin="" defer="defer"></script>' +
            '<script src="//s1.hdslb.com/bfs/static/jinkela/videoplay/vendor.b1b7706abd590dd295794f540f7669a5d8d978b3.js" crossorigin="" defer="defer"></script>' +
            '<script src="//s1.hdslb.com/bfs/static/jinkela/videoplay/video.b1b7706abd590dd295794f540f7669a5d8d978b3.js" crossorigin="" defer="defer"></script>' +
            '<script type="text/javascript" src="//static.hdslb.com/phoenix/dist/js/comment.min.js"></script>' +
            '<script type="text/javascript" src="//static.hdslb.com/js/jquery.qrcode.min.js"></script>' +
            '<link rel="stylesheet" href="//static.hdslb.com/phoenix/dist/css/comment.min.css" type="text/css">' +
            '<script type="text/javascript" src="//static.hdslb.com/common/js/footer.js"></script>';
        return wrb;
    }
    function wrWatchlater(oht){
        var html = '<!DOCTYPE html><html><head><meta name="spm_prefix" content="333.881"><link rel="stylesheet" href="//static.hdslb.com/phoenix/dist/css/comment.min.css" type="text/css"><link rel="stylesheet" href="//static.hdslb.com/elec_2/dist/css/later_elec.css" type="text/css"><link rel="stylesheet" href="//static.hdslb.com/tag/css/tag-index2.0.css" type="text/css"><script type="text/javascript">window.__BILI_CONFIG__={"show_bv":false}</script><script type="text/javascript">window.spmReportData={},window.reportConfig={sample:1,scrollTracker:!0,msgObjects:"spmReportData"}</script><script type="text/javascript" src="//s1.hdslb.com/bfs/seed/log/report/log-reporter.js"></script><link href="//s1.hdslb.com/bfs/static/jinkela/watchlater/css/watchlater.1.ba8f2751267792c1f4a5e3a14514e47c34afba61.css" rel="stylesheet"><link href="//s1.hdslb.com/bfs/static/phoenix/viewlater/static/css/main.d9641d2f4dc42228ea8c2650e1b98b0b.css" rel="stylesheet"></head><body><div class="z-top-container has-menu"></div><div id="watchlater-app"></div><div class="footer bili-footer"></div><script type="text/javascript">0</script><script type="text/javascript" src="//static.hdslb.com/js/jquery.min.js"></script><script type="text/javascript" src="//static.hdslb.com/js/jquery.qrcode.min.js"></script><script type="text/javascript" src="//s1.hdslb.com/bfs/seed/jinkela/header/header.js"></script><script type="text/javascript" src="//static.hdslb.com/common/js/footer.js"></script><script type="text/javascript" src="//static.hdslb.com/js/swfobject.js"></script><script type="text/javascript" src="//static.hdslb.com/js/video.min.js"></script><script type="text/javascript" src="//static.hdslb.com/account/bili_quick_login.js"></script><script type="text/javascript" src="//static.hdslb.com/phoenix/dist/js/comment.min.js"></script><script type="text/javascript" src="//static.hdslb.com/mstation/js/upload/moxie.js"></script><script type="text/javascript" src="//static.hdslb.com/mstation/js/upload/plupload.js"></script><script type="text/javascript" src="//static.hdslb.com/elec_2/dist/js/later_elec.js"></script><script type="text/javascript" src="//s1.hdslb.com/bfs/static/jinkela/watchlater/1.watchlater.ba8f2751267792c1f4a5e3a14514e47c34afba61.js"></script><script type="text/javascript" src="//s1.hdslb.com/bfs/static/jinkela/watchlater/watchlater.ba8f2751267792c1f4a5e3a14514e47c34afba61.js"></script></body></html>';
        document.open();
        document.write(html);
        document.close();
    }
})();