/* This file is @generated by `ts-node scripts/build.ts`, DO NOT EDIT IT MANUALLY! */ /* prettier-ignore */ /* eslint-disable */ // ==UserScript== // @name B 站网页端直播 // @namespace ProgramRipper // @version 0.2.4 // @author ProgramRipper // @license MIT // @description 在 B 站网页端开播 // @homepage https://github.com/ProgramRipper/BLiveWeb // @icon https://www.bilibili.com/favicon.ico // @updateURL https://hub.hanbi.live/ProgramRipper/BLiveWeb/refs/heads/master/lib/index.user.js // @downloadURL https://hub.hanbi.live/ProgramRipper/BLiveWeb/refs/heads/master/lib/index.user.js // @supportURL https://github.com/ProgramRipper/BLiveWeb/issues // @match *://link.bilibili.com/* // @connect api.live.bilibili.com // @connect * // @grant unsafeWindow // @run-at document-start // ==/UserScript== var E=Object.create;var _=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var S=(c,p)=>()=>(p||c((p={exports:{}}).exports,p),p.exports);var C=(c,p,a,l)=>{if(p&&typeof p=="object"||typeof p=="function")for(let s of I(p))!W.call(c,s)&&s!==a&&_(c,s,{get:()=>p[s],enumerable:!(l=H(p,s))||l.enumerable});return c};var G=(c,p,a)=>(a=c!=null?E(U(c)):{},C(p||!c||!c.__esModule?_(a,"default",{value:c,enumerable:!0}):a,c));var w=S((J,F)=>{(function(){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p={rotl:function(a,l){return a<>>32-l},rotr:function(a,l){return a<<32-l|a>>>l},endian:function(a){if(a.constructor==Number)return p.rotl(a,8)&16711935|p.rotl(a,24)&4278255360;for(var l=0;l0;a--)l.push(Math.floor(Math.random()*256));return l},bytesToWords:function(a){for(var l=[],s=0,u=0;s>>5]|=a[s]<<24-u%32;return l},wordsToBytes:function(a){for(var l=[],s=0;s>>5]>>>24-s%32&255);return l},bytesToHex:function(a){for(var l=[],s=0;s>>4).toString(16)),l.push((a[s]&15).toString(16));return l.join("")},hexToBytes:function(a){for(var l=[],s=0;s>>6*(3-f)&63)):l.push("=");return l.join("")},base64ToBytes:function(a){a=a.replace(/[^A-Z0-9+\/]/ig,"");for(var l=[],s=0,u=0;s>>6-u*2);return l}};F.exports=p})()});var m=S((z,x)=>{var T={utf8:{stringToBytes:function(c){return T.bin.stringToBytes(unescape(encodeURIComponent(c)))},bytesToString:function(c){return decodeURIComponent(escape(T.bin.bytesToString(c)))}},bin:{stringToBytes:function(c){for(var p=[],a=0;a{b.exports=function(c){return c!=null&&(B(c)||X(c)||!!c._isBuffer)};function B(c){return!!c.constructor&&typeof c.constructor.isBuffer=="function"&&c.constructor.isBuffer(c)}function X(c){return typeof c.readFloatLE=="function"&&typeof c.slice=="function"&&B(c.slice(0,0))}});var k=S((Z,R)=>{(function(){var c=w(),p=m().utf8,a=L(),l=m().bin,s=function(u,f){u.constructor==String?f&&f.encoding==="binary"?u=l.stringToBytes(u):u=p.stringToBytes(u):a(u)?u=Array.prototype.slice.call(u,0):!Array.isArray(u)&&u.constructor!==Uint8Array&&(u=u.toString());for(var o=c.bytesToWords(u),h=u.length*8,e=1732584193,r=-271733879,n=-1732584194,t=271733878,i=0;i>>24)&16711935|(o[i]<<24|o[i]>>>8)&4278255360;o[h>>>5]|=128<>>9<<4)+14]=h;for(var d=s._ff,v=s._gg,g=s._hh,y=s._ii,i=0;i>>0,r=r+O>>>0,n=n+M>>>0,t=t+P>>>0}return c.endian([e,r,n,t])};s._ff=function(u,f,o,h,e,r,n){var t=u+(f&o|~f&h)+(e>>>0)+n;return(t<>>32-r)+f},s._gg=function(u,f,o,h,e,r,n){var t=u+(f&h|o&~h)+(e>>>0)+n;return(t<>>32-r)+f},s._hh=function(u,f,o,h,e,r,n){var t=u+(f^o^h)+(e>>>0)+n;return(t<>>32-r)+f},s._ii=function(u,f,o,h,e,r,n){var t=u+(o^(f|~h))+(e>>>0)+n;return(t<>>32-r)+f},s._blocksize=16,s._digestsize=16,R.exports=function(u,f){if(u==null)throw new Error("Illegal argument "+u);var o=c.wordsToBytes(s(u,f));return f&&f.asBytes?o:f&&f.asString?l.bytesToString(o):c.bytesToHex(o)}})()});var q=G(k());(()=>{let c=window.fetch,p=XMLHttpRequest.prototype.open,a=Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype,"responseText").get,l;XMLHttpRequest.prototype.open=function(s,u,f=!0,o=null,h=null){let{host:e,pathname:r,searchParams:n}=new URL(u.startsWith("//")?"https:"+u:u);switch([s,e,r].toString()){case["GET","api.live.bilibili.com","/room/v1/Area/getMyChooseArea"].toString():l=n.get("roomid");break;case["GET","api.live.bilibili.com","/xlive/app-blink/v1/live/GetWebLivePermission"].toString():Object.defineProperty(this,"responseText",{get(){let t=JSON.parse(a.call(this));return t.data.allow_live?XMLHttpRequest.prototype.open=p:t.data.allow_live=!0,JSON.stringify(t)}});break;case["POST","api.live.bilibili.com","/xlive/app-blink/v1/live/FetchWebUpStreamAddr"].toString():this.send=async()=>{let t=await(await c(`https://api.live.bilibili.com/live_stream/v1/StreamList/get_stream_by_roomId?room_id=${l}`,{mode:"cors",credentials:"include"})).json();t.data.addr=t.data.rtmp,t.data.line=t.data.stream_line,delete t.data.rtmp,delete t.data.stream_line,Object.defineProperties(this,{readyState:{value:4},status:{value:200},responseText:{value:JSON.stringify(t)}}),this.dispatchEvent(new Event("load")),this.dispatchEvent(new Event("readystatechange"))};break}p.call(this,s,u,f,o,h)},(unsafeWindow||window).fetch=(s,u)=>{let f=typeof s=="string"?s:s instanceof Request?s.url:s.toString(),{host:o,pathname:h,searchParams:e}=new URL(f.startsWith("//")?"https:"+f:f);switch([u?.method??"GET",o,h].toString()){case["POST","api.live.bilibili.com","/xlive/app-blink/v1/streaming/WebLiveCenterStartLive"].toString():let r=new URLSearchParams({access_key:"",appkey:"aae92bc66f3edfab",area_v2:e.get("area_v2")??"",build:"9343",csrf:e.get("csrf")??"",csrf_token:e.get("csrf_token")??"",platform:"pc_link",room_id:e.get("room_id")??"",ts:Math.floor(Date.now()/1e3).toString()});return r.sort(),r.set("sign",(0,q.default)(r.toString()+"af125a0d5279fd576c1b4418a3e8276d")),c("https://api.live.bilibili.com/room/v1/Room/startLive",{body:r,method:"POST",mode:"cors",credentials:"include"})}return c(s,u)}})();