// ==UserScript== // @name Give me AV not BV // @namespace https://xsky123.com // @version 0.2a // @description F**king Bilibili, give my av number back! // @author XSky123 // @require https://unpkg.com/ajax-hook@2.0.0/dist/ajaxhook.min.js // @match https://www.bilibili.com/video/* // @match https://acg.tv/* // @match https://b23.tv/* // @grant none // @downloadURL none // ==/UserScript== if(window.location.href.match(/.*bilibili.com\/video\/BV.*/)){ var p_match = window.location.href.match(/\?p\=(\d+)/); // Detect P, though a little ugly : P var url = "https://www.bilibili.com/video/av"+window.__INITIAL_STATE__.aid; if(p_match){ url += p_match[0]; } window.location.href=url; console.log("F**k You BV Number!"); } var is_finished_ajax = false; var is_av_number_written = false; ah.proxy({ //请求发起前进入 onRequest: (config, handler) => { if(config.url.indexOf("first_video_frame_decoded")!=-1){ //console.log(config.url) is_finished_ajax = true; } handler.next(config); }, //请求成功后进入 onResponse: (response, handler) => { //console.log(response.response) if(is_finished_ajax && !is_av_number_written){ document.getElementsByClassName("video-data")[0].innerHTML += "    av"+window.__INITIAL_STATE__.aid+""; is_av_number_written = true; } handler.next(response) } })