// ==UserScript==
// @name Bilibili 旧播放页
// @namespace https://greasyfork.org/zh-CN/scripts/394296
// @version 2.2.1
// @description 切换旧版播放页面,布局、播放器全部切换回2019年12月09日之前的样子。
// @author Motoori Kashin
// @match *://*.bilibili.com/video/av*
// @match *://*.bilibili.com/watchlater/*
// @match *://*.bilibili.com/bangumi/play/ss*
// @match *://*.bilibili.com/bangumi/play/ep*
// @license MIT
// @run-at document-start
// @grant none
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
//window.stop();/*阻止原页面继续加载,但配合`@run-at document-start`在chrmoe中可能会导致无法替换失败*/
//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;/*获取原始数据供旧播放页使用*/
if (OHTML.match(/biliconfig/) == null){wrVideo(OHTML);}
}
var reh = setInterval(function(){/*处理av页版头问题*/
var rehead = document.getElementsByClassName("bili-header-m")[1];
if (rehead){
rehead.remove();
clearInterval(reh);
}
}, 10);
}
if(location.pathname.startsWith('/watchlater')) {
const xhr = new XMLHttpRequest();/*缓解稍后再看切换失败的问题*/
xhr.open('GET', window.location.href, false);
xhr.send(null);
if (xhr.status === 200) {
const OHTML = xhr.responseText;
wrWatchlater(OHTML);
}
}
if(location.pathname.startsWith('/bangumi')) {
const xhr = new XMLHttpRequest();
xhr.open('GET', window.location.href, false);
xhr.send(null);
if (xhr.status === 200) {
const OHTML = xhr.responseText;/*获取原始数据供旧播放页使用*/
wrBangumi(OHTML);
}
}
var cdm = setInterval(function(){/*自动切换到弹幕列表*/
var dmlist = document.getElementsByClassName("bilibili-player-filter-btn")[1];
if (dmlist){
dmlist.click();
clearInterval(cdm);
}
}, 10);
function wrVideo(oht){
var html = oht;
var wrh = html.match(/' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'';
return wrb;
}
function wrWatchlater(oht){
var html = '';
document.open();
document.write(html);
document.close();
}
function wrBangumi(oht){
var html = oht;
//var bgms = html.match(/' +
'' +
'' +
'' +
'' +
'';
html = html.replace(/<\/head>/g,wrh);
var wrb = bgmBody();
html = html.replace(/xxx/g,wrb);
document.open();
document.write(html);
document.close();
}
function bgmBody(){
var wrb = '' +
'' +
'' +
'' +
'' +
'' +
'' +
'';
return wrb;
}
})();