/**
 * 本模块负责重写av/BV页，由`rewrite.js`按需引导
 * 其他只在重写过的旧版页面生效的功能可添加在本模块中，但更推荐编写在单独的模块中然后将引导代码写在本模块中。
 */ /**
 * 本模块负责重写av/BV页，由`rewrite.js`按需引导
 * 其他只在重写过的旧版页面生效的功能可添加在本模块中，但更推荐编写在单独的模块中然后将引导代码写在本模块中。
 */ ( function ( ) { try { class Av { isAV__INITIAL_STATE__ = ( pet ) : pet is AV__INITIAL_STATE__ => true ; constructor ( ) { if ( /\/s\// . test ( location . href ) ) location . replace ( location . href . replace ( "s/video" , "video" ) ) ; API . path . name = "av" ; if ( API . path [ 4 ] . toLowerCase ( ) . startsWith ( 'bv' ) ) API . aid = < number > API . abv ( API . path [ 4 ] . split ( "#" ) [ 0 ] . split ( "?" ) [ 0 ] ) ; API . aid = API . aid || Number ( ( < RegExpExecArray > /[0-9]+/ . exec ( String ( API . path [ 4 ] ) ) ) [ 0 ] ) ; config . rewriteMethod == "异步" ? this . prepareA ( ) : this . prepareB ( ) ; } /**
             * 异步构造__INITIAL_STATE__前置
             */ async prepareA ( ) { await new Promise ( r => { ( < Promise < JSON > > xhr ( { url : API . objUrl ( "https://api.bilibili.com/x/web-interface/view/detail" , { aid : < any > API . aid } ) , responseType : "json" , credentials : true } ) ) . then ( d => { API . importModule ( "av-detail.js" , { __INITIAL_STATE__ : d } , true ) ; r ( true ) ; } ) . catch ( e => { toast . error ( "获取av号信息出错，尝试访问第三方接口~" , e ) ; ( < Promise < JSON > > xhr ( { url : API . objUrl ( "https://www.biliplus.com/api/view" , { id : < any > API . aid } ) , responseType : "json" } ) ) . then ( d => { API . importModule ( "av-biliplus.js" , { __INITIAL_STATE__ : d } , true ) ; r ( true ) ; } ) . catch ( e => { toast . error ( "第三方接口也出错，" , e ) ; API . importModule ( "vector.js" ) ; } ) ; } ) ; } ) ; this . write ( ) ; } /**
             * 同步构造__INITIAL_STATE__前置
             */ prepareB ( ) { let d = xhr ( { url : API . objUrl ( "https://api.bilibili.com/x/web-interface/view/detail" , { aid : < any > API . aid } ) , async : false , credentials : true } ) ; try { API . importModule ( "av-detail.js" , { __INITIAL_STATE__ : d } , true ) ; } catch ( e ) { toast . error ( "获取av号信息出错，尝试访问第三方接口~" , e ) ; d = xhr ( { url : API . objUrl ( "https://www.biliplus.com/api/view" , { id : < any > API . aid } ) , async : false } ) ; API . importModule ( "av-biliplus.js" , { __INITIAL_STATE__ : d } , true ) ; } this . write ( ) ; } /**
             * 实际重写页面过程，依赖__INITIAL_STATE__前置
             */ write ( ) { if ( this . isAV__INITIAL_STATE__ ( API . __INITIAL_STATE__ ) ) { if ( ! API . __INITIAL_STATE__ ) throw "无法重写av页 ಥ_ಥ" ; if ( API . __INITIAL_STATE__ . videoData . redirect_url ) return toast . warning ( "番剧重定向..." , API . __INITIAL_STATE__ . videoData . redirect_url ) ; if ( API . __INITIAL_STATE__ . videoData . stein_guide_cid ) return ( delete API . path . name , toast . warning ( "这似乎是个互动视频！" , "抱歉！旧版播放器无法支持 ಥ_ಥ" ) , API . importModule ( "vector.js" ) ) ; API . restorePlayerSetting ( ) ; API . scriptIntercept ( [ "video-nano" ] ) ; API . scriptIntercept ( [ "stardust-video" ] ) ; API . aid = API . __INITIAL_STATE__ . aid ; API . tid = API . __INITIAL_STATE__ . videoData . tid ; ( < any > window ) . __INITIAL_STATE__ = API . __INITIAL_STATE__ ; config . noVideo && delete ( < any > window ) . __playinfo__ ; API . rewriteHTML ( config . trusteeship ? API . getModule ( "av.html" ) . replace ( "static.hdslb.com/js/video.min.js" , "cdn.jsdelivr.net/gh/MotooriKashin/Bilibili-Old/dist/video.min.js" ) : API . getModule ( "av.html" ) ) ; document . title = API . __INITIAL_STATE__ . videoData . title + "_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili" ; API . addCss ( API . getModule ( "bofqi.css" ) ) ; API . runWhile ( ( ) => document . getElementsByClassName ( "bili-header-m report-wrap-module" ) [ 1 ] , ( ) => document . getElementsByClassName ( "bili-header-m report-wrap-module" ) [ 1 ] . remove ( ) ) ; ( < any > window ) . commentAgent = { seek : ( t ) => ( < any > window ) . player && ( < any > window ) . player . seek ( t ) } ; config . enlike && API . importModule ( "enLike.js" ) ; sessionStorage . getItem ( "medialist" ) && API . importModule ( "mediaList.js" ) ; config . upList && API . __INITIAL_STATE__ . videoData . staff && API . importModule ( "upList.js" , { staff : API . __INITIAL_STATE__ . videoData . staff } ) ; API . importModule ( "descBV.js" ) ; API . importModule ( "hookWebpackJsonp.js" ) ; config . commandDm && API . importModule ( "commandDm.js" ) ; API . importModule ( "videoSort.js" ) ; API . importModule ( "mediaControl.js" , { getPlaylistIndex : ( ) => ( < any > window ) . player . getPlaylistIndex ( ) , mediaInfo : ( pid , playList ) => { if ( this . isAV__INITIAL_STATE__ ( API . __INITIAL_STATE__ ) ) return { title : API . __INITIAL_STATE__ . videoData . title , artist : API . __INITIAL_STATE__ . videoData . owner . name , chapterName : playList [ pid ] . part , coverUrl : [ { src : API . __INITIAL_STATE__ . videoData . pic , sizes : "320x180" } ] } ; } } ) ; config . electric && API . jsonphook ( [ "api.bilibili.com/x/web-interface/elec/show" ] , function ( xhr ) { xhr . url = API . objUrl ( xhr . url . split ( "?" ) [ 0 ] , Object . assign ( API . urlObj ( xhr . url ) , { aid : 1 , mid : 1 } ) ) ; } ) ; } } } new Av ( ) ; } catch ( e ) { debug . error ( "av.js" , e ) ; API . importModule ( "vector.js" ) ; } } ) ( ) ;