// ==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
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
//window.stop();/*阻止原页面继续加载,但配合`@run-at document-start`可能会导致无法替换失败*/
//document.open();document.write('
loading
');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(/' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'';
return wrb;
}
function wrWatchlater(oht){
var html = '';
document.open();
document.write(html);
document.close();
}
})();