/**
 * 本模块hook了Worker以使旧版播放器支持新版proto弹幕
 */ /**
 * 本模块hook了Worker以使旧版播放器支持新版proto弹幕
 */ ( function ( ) { try { let workerPostMsg = Worker . prototype . postMessage ; let list_so ; Worker . prototype . postMessage = function ( aMessage , transferList ) { if ( aMessage . url && aMessage . url . includes ( "list.so" ) ) { list_so = this ; let triggerOnMsg = ( danmaku , loadTime , parseTime ) => list_so . onmessage ( { data : { code : 0 , danmakuArray : danmaku , loadTime : loadTime , parseTime : parseTime , sendTip : "" , state : 0 , textSide : "" , total : danmaku . length . toString ( ) } } ) ; let loadDanmaku = ( loadTime ) => API . getSegDanmaku ( ) . then ( ( Segments ) => { loadTime = ( < any > new Date ( ) ) - loadTime ; let parseTime = new Date ( ) ; let danmaku = API . danmakuFormat ( Segments ) ; parseTime = ( < any > new Date ( ) ) - parseTime ; triggerOnMsg ( danmaku , loadTime , parseTime ) ; API . danmaku = danmaku ; } ) ; if ( ( < any > XMLHttpRequest . prototype ) . pakku_send === undefined ) { loadDanmaku ( new Date ( ) ) ; } else { let url = "https://api.bilibili.com/x/v2/dm/web/seg.so?type=1&oid=" + API . cid + "&pid=" + API . aid + "&segment_index=1" ; xhr ( { url : url , responseType : "arraybuffer" , credentials : true } ) . then ( ( response ) => { let Segments = API . segDmDecode ( response ) ; let i = 1 ; for ( ; i < Segments . length ; i ++ ) { if ( Segments [ i - 1 ] . progress > Segments [ i ] . progress ) break ; } if ( i != Segments . length ) loadDanmaku ( new Date ( ) ) ; else { triggerOnMsg ( API . danmaku = API . danmakuFormat ( Segments ) , "(pakku.js)" , "(pakku.js)" ) ; } } ) ; } } else { workerPostMsg . call ( this , aMessage , < any > transferList ) ; } } ; } catch ( e ) { toast . error ( "worker.js" , e ) ; } } ) ( ) ; declare namespace API { /**
     * 记录弹幕用于下载
     */ let danmaku ; }