// ==UserScript== // @name Give me AV not BV // @namespace https://xsky123.com // @version 0.3 // @description F**king Bilibili, give my av number back! // @author XSky123 // @match https://www.bilibili.com/video/* // @match https://acg.tv/* // @match https://b23.tv/* // @run-at document-end // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; 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 comment_match = window.location.hash.substr('#',6)=='#reply'; // Detect Comment Hash Mark var url = "https://www.bilibili.com/video/av"+window.__INITIAL_STATE__.aid; if(p_match){ url += p_match[0]; } if(comment_match){ url += window.location.hash; } history.replaceState(null, null,url); console.log("[AVnoBV] F**k You BV Number!"); } var is_finished_ajax = false; var is_av_number_written = false; var _current_url = ""; var MutationObserver = window.MutationObserver; var PageBodyElement = document.querySelector("body"); var DocumentObserverConfig = { attributes: true, childList: true, characterData: true, subtree: true }; var ObserverDetectAndAddAVNumber = function(mutationsList) { //console.log("changed"); if(document.getElementsByClassName("view")){ //console.log(document.getElementsByClassName("view").innerHTML); if(document.getElementsByClassName("view")[0].innerHTML.match(/\d+/)){ document.getElementsByClassName("video-data")[1].innerHTML += "    av"+window.__INITIAL_STATE__.aid+""; console.log("[AVnoBV] Add av number successfully!"); RanderFinishObserver.disconnect(); } } }; var RanderFinishObserver = new MutationObserver(ObserverDetectAndAddAVNumber); RanderFinishObserver.observe(PageBodyElement, DocumentObserverConfig); })();