// ==UserScript== // @name 重写av页实验 // @namespace Motoori Kashin // @version 0.1 // @description 测试中的脚本,基本不能使用,希望能作为大家的参考。重写的最简陋的b战av页播放器(没有任何布局!),弹幕列表消失的话可以试着往下滚就恢复了。 // @author Motoori Kashin // @match *://*.bilibili.com/video/av* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; window.stop(); // 新版av页2019年10月26 10:00起已经不适用定时器延时载入Element了,全都用promise!所以这里失效了ಥ_ಥ。 /*var highestTimeoutId = setTimeout(";"); for (var i = 0 ; i < highestTimeoutId ; i++) { clearTimeout(i);//清除所有定时器,防止后续Element载入 }*/ const xhr = new XMLHttpRequest(); xhr.open('GET', window.location.href);// 返回新播放页,为重写提供可能需要的数据,仅作为测试的话用不到 xhr.onload = () => { var html = xhr.responseText.replace(//g,"");// ---------------------清空所有' + '' html = html.replace(/<\/head>/g,wrh); // 开始重写,这里未调用任何新版播放页返回的数据直接写最基本框架来测试(去除了所有依赖av号数据的内容) var wrb = '
' + // 两个最基本的js脚本,第二个应该就是旧版播放器 '' + '' + '
' + '' + '
' + // 2018年5月2日旧版av页的主体部分,网页显示全部内容都在这个id="app"的div里,其中很多内容(后端直接写在网页里的)需要依赖上面新av页数据返回来修改(或者用api重新获取),这里为了测试删除了下级所有标签(包括上面那个关键脚本可能依赖的标签) '
'; // 用重写的替换占位的"xxx" html = html.replace(/xxx/g,wrb); document.open(); document.write(html); // 原想延迟6s等后续的Element载入完再重写网页,后来发现延迟载入的那些脚本好像并没有什么妨碍,最多引入了部分av信息和评论区 //setTimeout(function(){document.write(html);},6000); // 播放器会被某个js或css自动缩小(没有定位到是哪个家伙干的ಥ_ಥ),所以延时把style清空 setTimeout(function(){document.getElementById('bofqi').style = "";},2000); document.close(); }; xhr.send(); })();