Rules-For-Quantumult-X/Scripts/Unlock/BiliBili-proto.js

183 lines
194 KiB
JavaScript
Raw Normal View History

2022-12-13 09:58:10 +08:00
let protobuf;!function(g){"use strict";!function(r,e,t){var i=function t(i){var n=e[i];return n||r[i][0].call(n=e[i]={exports:{}},t,n,n.exports),n.exports}(t[0]);protobuf=i.util.global.protobuf=i,"function"==typeof define&&define.amd&&define(["long"],function(t){return t&&t.isLong&&(i.util.Long=t,i.configure()),i}),"object"==typeof module&&module&&module.exports&&(module.exports=i)}({1:[function(t,i,n){i.exports=function(t,i){var n=Array(arguments.length-1),s=0,r=2,u=!0;for(;r<arguments.length;)n[s++]=arguments[r++];return new Promise(function(r,e){n[s]=function(t){if(u)if(u=!1,t)e(t);else{for(var i=Array(arguments.length-1),n=0;n<i.length;)i[n++]=arguments[n];r.apply(null,i)}};try{t.apply(i||null,n)}catch(t){u&&(u=!1,e(t))}})}},{}],2:[function(t,i,n){n.length=function(t){var i=t.length;if(!i)return 0;for(var n=0;1<--i%4&&"="==(t[0|i]||"");)++n;return Math.ceil(3*t.length)/4-n};for(var f=Array(64),h=Array(123),r=0;r<64;)h[f[r]=r<26?r+65:r<52?r+71:r<62?r-4:r-59|43]=r++;n.encode=function(t,i,n){for(var r,e=null,s=[],u=0,o=0;i<n;){var h=t[i++];switch(o){case 0:s[u++]=f[h>>2],r=(3&h)<<4,o=1;break;case 1:s[u++]=f[r|h>>4],r=(15&h)<<2,o=2;break;case 2:s[u++]=f[r|h>>6],s[u++]=f[63&h],o=0}8191<u&&((e=e||[]).push(String.fromCharCode.apply(String,s)),u=0)}return o&&(s[u++]=f[r],s[u++]=61,1===o&&(s[u++]=61)),e?(u&&e.push(String.fromCharCode.apply(String,s.slice(0,u))),e.join("")):String.fromCharCode.apply(String,s.slice(0,u))};var c="invalid encoding";n.decode=function(t,i,n){for(var r,e=n,s=0,u=0;u<t.length;){var o=t.charCodeAt(u++);if(61==o&&1<s)break;if((o=h[o])===g)throw Error(c);switch(s){case 0:r=o,s=1;break;case 1:i[n++]=r<<2|(48&o)>>4,r=o,s=2;break;case 2:i[n++]=(15&r)<<4|(60&o)>>2,r=o,s=3;break;case 3:i[n++]=(3&r)<<6|o,s=0}}if(1===s)throw Error(c);return n-e},n.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}},{}],3:[function(t,i,n){function a(i,n){"string"==typeof i&&(n=i,i=g);var h=[];function f(t){if("string"!=typeof t){var i=c();if(a.verbose&&console.log("codegen: "+i),i="return "+i,t){for(var n=Object.keys(t),r=Array(n.length+1),e=Array(n.length),s=0;s<n.length;)r[s]=n[s],e[s]=t[n[s++]];return r[s]=i,Function.apply(null,r).apply(null,e)}return Function(i)()}for(var u=Array(arguments.length-1),o=0;o<u.length;)u[o]=arguments[++o];if(o=0,t=t.replace(/%([%dfijs])/g,function(t,i){var n=u[o++];switch(i){case"d":case"f":return""+ +(""+n);case"i":return""+Math.floor(n);case"j":return JSON.stringify(n);case"s":return""+n}return"%"}),o!==u.length)throw Error("parameter count mismatch");return h.push(t),f}function c(t){return"function "+(t||n||"")+"("+(i&&i.join(",")||"")+"){\n "+h.join("\n ")+"\n}"}return f.toString=c,f}(i.exports=a).verbose=!1},{}],4:[function(t,i,n){function r(){this.t={}}(i.exports=r).prototype.on=function(t,i,n){return(this.t[t]||(this.t[t]=[])).push({fn:i,ctx:n||this}),this},r.prototype.off=function(t,i){if(t===g)this.t={};else if(i===g)this.t[t]=[];else for(var n=this.t[t],r=0;r<n.length;)n[r].fn===i?n.splice(r,1):++r;return this},r.prototype.emit=function(t){var i=this.t[t];if(i){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<i.length;)i[r].fn.apply(i[r++].ctx,n)}return this}},{}],5:[function(t,i,n){i.exports=o;var s=t(1),u=t(7)("fs");function o(n,r,e){return r="function"==typeof r?(e=r,{}):r||{},e?!r.xhr&&u&&u.readFile?u.readFile(n,function(t,i){return t&&"undefined"!=typeof XMLHttpRequest?o.xhr(n,r,e):t?e(t):e(null,r.binary?i:i.toString("utf8"))}):o.xhr(n,r,e):s(o,this,n,r)}o.xhr=function(t,n,r){var e=new XMLHttpRequest;e.onreadystatechange=function(){if(4!==e.readyState)return g;if(0!==e.status&&200!==e.status)return r(Error("status "+e.status));if(n.binary){if(!(t=e.response))for(var t=[],i=0;i<e.responseText.length;++i)t.push(255&e.responseText.charCodeAt(i));return r(null,"undefined"!=typeof Uint8Array?new Uint8Array(t):t)}return r(null,e.responseText)},n.binary&&("overrideMimeType"in e&&e.overrideMimeType("text/plain; charset=x-user-defined"),e.responseType="arraybuffer"),e.open("GET",t),e.send()}},{1:1,7:7}],6:[function(t,
2022-10-29 11:42:12 +08:00
// pako 2.0.4
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).pako={})}(this,(function(t){"use strict";function e(t){let e=t.length;for(;--e>=0;)t[e]=0}const a=256,i=286,n=30,s=15,r=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),l=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),o=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),d=new Array(576);e(d);const _=new Array(60);e(_);const f=new Array(512);e(f);const c=new Array(256);e(c);const u=new Array(29);e(u);const w=new Array(n);function b(t,e,a,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}let g,p,m;function k(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}e(w);const v=t=>t<256?f[t]:f[256+(t>>>7)],y=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},x=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,y(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=a-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=a)},z=(t,e,a)=>{x(t,a[2*e],a[2*e+1])},A=(t,e)=>{let a=0;do{a|=1&t,t>>>=1,a<<=1}while(--e>0);return a>>>1},E=(t,e,a)=>{const i=new Array(16);let n,r,l=0;for(n=1;n<=s;n++)i[n]=l=l+a[n-1]<<1;for(r=0;r<=e;r++){let e=t[2*r+1];0!==e&&(t[2*r]=A(i[e]++,e))}},R=t=>{let e;for(e=0;e<i;e++)t.dyn_ltree[2*e]=0;for(e=0;e<n;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},Z=t=>{t.bi_valid>8?y(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},U=(t,e,a,i)=>{const n=2*e,s=2*a;return t[n]<t[s]||t[n]===t[s]&&i[e]<=i[a]},S=(t,e,a)=>{const i=t.heap[a];let n=a<<1;for(;n<=t.heap_len&&(n<t.heap_len&&U(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!U(e,i,t.heap[n],t.depth));)t.heap[a]=t.heap[n],a=n,n<<=1;t.heap[a]=i},D=(t,e,i)=>{let n,s,o,h,d=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*d]<<8|t.pending_buf[t.d_buf+2*d+1],s=t.pending_buf[t.l_buf+d],d++,0===n?z(t,s,e):(o=c[s],z(t,o+a+1,e),h=r[o],0!==h&&(s-=u[o],x(t,s,h)),n--,o=v(n),z(t,o,i),h=l[o],0!==h&&(n-=w[o],x(t,n,h)))}while(d<t.last_lit);z(t,256,e)},T=(t,e)=>{const a=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,r=e.stat_desc.elems;let l,o,h,d=-1;for(t.heap_len=0,t.heap_max=573,l=0;l<r;l++)0!==a[2*l]?(t.heap[++t.heap_len]=d=l,t.depth[l]=0):a[2*l+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=d<2?++d:0,a[2*h]=1,t.depth[h]=0,t.opt_len--,n&&(t.static_len-=i[2*h+1]);for(e.max_code=d,l=t.heap_len>>1;l>=1;l--)S(t,a,l);h=r;do{l=t.heap[1],t.heap[1]=t.heap[t.heap_len--],S(t,a,1),o=t.heap[1],t.heap[--t.heap_max]=l,t.heap[--t.heap_max]=o,a[2*h]=a[2*l]+a[2*o],t.depth[h]=(t.depth[l]>=t.depth[o]?t.depth[l]:t.depth[o])+1,a[2*l+1]=a[2*o+1]=h,t.heap[1]=h++,S(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const a=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,r=e.stat_desc.has_stree,l=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,h=e.stat_desc.max_length;let d,_,f,c,u,w,b=0;for(c=0;c<=s;c++)t.bl_count[c]=0;for(a[2*t.heap[t.heap_max]+1]=0,d=t.heap_max+1;d<573;d++)_=t.heap[d],c=a[2*a[2*_+1]+1]+1,c>h&&(c=h,b++),a[2*_+1]=c,_>i||(t.bl_count[c]++,u=0,_>=o&&(u=l[_-o]),w=a[2*_],t.opt_len+=w*(c+u),r&&(t.static_len+=w*(n[2*_+1]+u)));if(0!==b){do{for(c=h-1;0===t.bl_count[c];)c--;t.bl_count[c]--,t.bl_count[c+1]+=2,t.bl_count[h]--,b-=2}while(b>0);for(c=h;0!==c;c--)for(_=t.bl_count[c];0!==_;)f=t.heap[--d],f>i||(a[2*f+1]!==c&&(t.opt_len+=(c-a[2*f+1])*a[2*f],a[2*f+1]=c),_--)}})(t,e),E(a,d,t.bl_count)},O=(t,e,a)=>{let i,n,s=-1,r=e[1],l=0,o=7,h=4;for(0===r&&(o=138,h=3),e[2*(a+1)+1]=65535,i=0;i<=a;i++)n=r,r=e[2*(i+1)+1],++l<o&&n===r||(l<h?t.bl_tree[2*n]+=l:0!==n?(n!==s&&t.bl_tree[2*n]++,t.bl_tree[32]++):l<=10?t.bl_tree[34]++:t.bl_tree[36]++,l=0,s=n,0===r?(o=138,h=3):n===r?(o=6,h=3):(o=7,h=4))},I=(t,e,a)=>{let i,n,s=-1,r=e[1],l=0,o=7,h=4;for(0===r&&(o=138
2022-12-13 09:58:10 +08:00
const biliJson = {"nested":{"bilibili":{"nested":{"ad":{"nested":{"v1":{"options":{"java_package":"com.smile.bilibili.model"},"nested":{"AdDto":{"fields":{"creativeId":{"type":"int64","id":1},"adCb":{"type":"string","id":2},"cmMark":{"type":"int32","id":4},"topViewId":{"type":"int64","id":5},"creativeType":{"type":"int32","id":6},"cardType":{"type":"int32","id":7},"creativeStyle":{"type":"int32","id":8},"isAd":{"type":"bool","id":9}}},"SourceContentDto":{"fields":{"adContent":{"type":"AdDto","id":9}}},"AdsControlDto":{"fields":{"hasDanmu":{"type":"int32","id":1},"cids":{"rule":"repeated","type":"int64","id":2}}}}}}},"app":{"nested":{"archive":{"nested":{"v1":{"options":{"java_package":"com.smile.bilibili.model"},"nested":{"Arc":{"fields":{"aid":{"type":"int64","id":1},"videos":{"type":"int64","id":2},"typeId":{"type":"int32","id":3},"typeName":{"type":"string","id":4},"copyright":{"type":"int32","id":5},"pic":{"type":"string","id":6},"title":{"type":"string","id":7},"pubdate":{"type":"int64","id":8},"ctime":{"type":"int64","id":9},"desc":{"type":"string","id":10},"state":{"type":"int32","id":11},"access":{"type":"int32","id":12},"attribute":{"type":"int32","id":13},"tag":{"type":"string","id":14},"tags":{"rule":"repeated","type":"string","id":15},"duration":{"type":"int64","id":16},"missionId":{"type":"int64","id":17},"orderId":{"type":"int64","id":18},"redirectUrl":{"type":"string","id":19},"forward":{"type":"int64","id":20},"rights":{"type":"Rights","id":21},"author":{"type":"Author","id":22},"stat":{"type":"Stat","id":23},"reportResult":{"type":"string","id":24},"dynamic":{"type":"string","id":25},"firstCid":{"type":"int64","id":26},"dimension":{"type":"Dimension","id":27},"staffInfo":{"rule":"repeated","type":"StaffInfo","id":28},"seasonId":{"type":"int64","id":29},"attributeV2":{"type":"int64","id":30},"shortLinkV2":{"type":"string","id":40},"upFromV2":{"type":"int32","id":41},"firstFrame":{"type":"string","id":42}}},"Rights":{"fields":{"bp":{"type":"int32","id":1},"elec":{"type":"int32","id":2},"download":{"type":"int32","id":3},"movie":{"type":"int32","id":4},"pay":{"type":"int32","id":5},"hd5":{"type":"int32","id":6},"noReprint":{"type":"int32","id":7},"autoplay":{"type":"int32","id":8},"ugcPay":{"type":"int32","id":9},"isCooperation":{"type":"int32","id":10},"ugcPayPreview":{"type":"int32","id":11},"noBackground":{"type":"int32","id":12}}},"Author":{"fields":{"mid":{"type":"int64","id":1},"name":{"type":"string","id":2},"face":{"type":"string","id":3}}},"Stat":{"fields":{"aid":{"type":"int64","id":1},"view":{"type":"int32","id":2},"danmaku":{"type":"int32","id":3},"reply":{"type":"int32","id":4},"fav":{"type":"int32","id":5},"coin":{"type":"int32","id":6},"share":{"type":"int32","id":7},"nowRank":{"type":"int32","id":8},"hisRank":{"type":"int32","id":9},"like":{"type":"int32","id":10},"dislike":{"type":"int32","id":11}}},"StaffInfo":{"fields":{"mid":{"type":"int64","id":1},"title":{"type":"string","id":2},"attribute":{"type":"int64","id":3}}},"Dimension":{"fields":{"width":{"type":"int64","id":1},"height":{"type":"int64","id":2},"rotate":{"type":"int64","id":3}}},"Page":{"fields":{"cid":{"type":"int64","id":1},"page":{"type":"int32","id":2},"from":{"type":"string","id":3},"part":{"type":"string","id":4},"duration":{"type":"int64","id":5},"vid":{"type":"string","id":6},"desc":{"type":"string","id":7},"webLink":{"type":"string","id":8},"dimension":{"type":"Dimension","id":9},"firstFrame":{"type":"string","id":10}}}}}}},"dynamic":{"nested":{"v2":{"options":{"java_package":"com.smile.bilibili.model"},"nested":{"AdditionalButton":{"fields":{"type":{"type":"AddButtonType","id":1},"jumpStyle":{"type":"AdditionalButtonStyle","id":2},"jumpUrl":{"type":"string","id":3},"uncheck":{"type":"AdditionalButtonStyle","id":4},"check":{"type":"AdditionalButtonStyle","id":5},"status":{"type":"AdditionalButtonStatus","id":6},"clickType":{"type":"AdditionalButtonClickType","id":7}}},"AddButtonType":{"values":{"bt_none":0,"bt_jump":1,"bt_button":2}},"AdditionalButtonStatus":{"values":{"none":0,"uncheck":1,"check":2}},"AdditionalButto
2022-10-29 11:42:12 +08:00
2022-12-13 09:58:10 +08:00
console.log(`b站proto-2022.11.18`);
2022-10-29 11:42:12 +08:00
const url = $request.url;
const method = $request.method;
2022-12-13 09:58:10 +08:00
let headers = $response.headers;
const isQuanX = typeof $task !== "undefined";
2022-10-29 11:42:12 +08:00
const binaryBody = isQuanX ? new Uint8Array($response.bodyBytes) : $response.body;
2022-12-13 09:58:10 +08:00
let gzipStrName = 'grpc-encoding';
if(!headers[gzipStrName]){
// Loon QX做调整
console.log('响应头首字母大写');
gzipStrName = 'Grpc-Encoding';
}
const isGzipCompress = headers[gzipStrName] === 'gzip';
console.log(`isGzipCompress:${isGzipCompress}`);
const unGzipBody = isGzipCompress ? pako.ungzip(binaryBody.slice(5)) : binaryBody.slice(5);
headers[gzipStrName] = 'identity';
2022-10-29 11:42:12 +08:00
let body;
const biliRoot = protobuf.Root.fromJSON(biliJson);
let needProcessFlag = false;
2022-12-13 09:58:10 +08:00
if (method !== "POST") {
$notification.post(notifyTitle, "method错误:", method);
}
if(url.includes("Dynamic/DynAll")){
2022-10-29 11:42:12 +08:00
console.log('动态DynAll');
const dynAllReplyType = biliRoot.lookupType("bilibili.app.dynamic.DynAllReply");
2022-12-13 09:58:10 +08:00
let dynAllReplyObj = dynAllReplyType.decode(unGzipBody);
if(!dynAllReplyObj.topicList){
2022-10-29 11:42:12 +08:00
console.log('topicList为空');
} else {
needProcessFlag = true;
2022-12-13 09:58:10 +08:00
dynAllReplyObj.topicList = null;
2022-10-29 11:42:12 +08:00
console.log('推荐话题topicList去除');
}
2022-12-13 09:58:10 +08:00
if(!dynAllReplyObj.upList){
console.log('upList为空');
} else {
needProcessFlag = true;
dynAllReplyObj.upList = null;
console.log('最常访问upList去除');
}
if(!dynAllReplyObj.dynamicList?.list?.length){
2022-10-29 11:42:12 +08:00
console.log('动态列表list为空');
} else {
let adCount = 0;
2022-12-13 09:58:10 +08:00
dynAllReplyObj.dynamicList.list = dynAllReplyObj.dynamicList.list.filter(item => {
if(item.cardType !== 15){
2022-10-29 11:42:12 +08:00
return true;
}
adCount++;
return false;
});
2022-12-13 09:58:10 +08:00
if(adCount){
2022-10-29 11:42:12 +08:00
needProcessFlag = true;
}
console.log(`动态列表广告数量:${adCount}`);
}
2022-12-13 09:58:10 +08:00
if(needProcessFlag){
body = processNewBody(dynAllReplyType.encode(dynAllReplyObj).finish());
2022-10-29 11:42:12 +08:00
}
2022-12-13 09:58:10 +08:00
} else if(url.includes("View/View")){
2022-10-29 11:42:12 +08:00
console.log('视频播放页View/View');
const viewReplyType = biliRoot.lookupType("bilibili.app.view.ViewReply");
2022-12-13 09:58:10 +08:00
let viewReplyObj = viewReplyType.decode(unGzipBody);
if(!viewReplyObj.cms?.length){
2022-10-29 11:42:12 +08:00
console.log('cms为空');
} else {
let adCount = 0;
const sourceContentDtoType = biliRoot.lookupType("bilibili.ad.v1.SourceContentDto");
2022-12-13 09:58:10 +08:00
for(let i = 0; i < viewReplyObj.cms.length; i++){
let item = viewReplyObj.cms[i];
if(item.sourceContent?.value){
2022-10-29 11:42:12 +08:00
// 注意这里虽然proto没有属性value 但是viewReplyMessage解析的有
2022-12-13 09:58:10 +08:00
const sourceContentDtoObj = sourceContentDtoType.decode(item.sourceContent.value);
if(sourceContentDtoObj.adContent){
2022-10-29 11:42:12 +08:00
adCount++;
}
}
}
2022-12-13 09:58:10 +08:00
viewReplyObj.cms = [];
2022-10-29 11:42:12 +08:00
console.log(`up主推荐广告:${adCount}`);
2022-12-13 09:58:10 +08:00
if(adCount){
2022-10-29 11:42:12 +08:00
needProcessFlag = true;
}
}
2022-12-13 09:58:10 +08:00
if(!viewReplyObj.relates?.length){
2022-10-29 11:42:12 +08:00
console.log('relates相关推荐为空');
} else {
let adCount = 0;
2022-12-13 09:58:10 +08:00
viewReplyObj.relates = viewReplyObj.relates.filter(item => {
if(item.goto === 'cm'){
2022-10-29 11:42:12 +08:00
adCount++;
return false;
}
return true;
});
console.log(`相关推荐广告:${adCount}`);
2022-12-13 09:58:10 +08:00
if(adCount){
2022-10-29 11:42:12 +08:00
needProcessFlag = true;
}
}
2022-12-13 09:58:10 +08:00
const adsControlValue = viewReplyObj.cmConfig?.adsControl?.value;
if(adsControlValue){
const adsControlDtoType = biliRoot.lookupType("bilibili.ad.v1.AdsControlDto");
const adsControlDtoObj = adsControlDtoType.decode(adsControlValue);
if(adsControlDtoObj?.hasDanmu === 1 || adsControlDtoObj?.cids?.length > 0){
console.log(`up主推荐广告-弹幕. ${adsControlDtoObj?.hasDanmu}, ${adsControlDtoObj?.cids}`);
viewReplyObj.cmConfig = null;
needProcessFlag = true;
}
}
if(needProcessFlag){
let tIconMap = viewReplyObj.tIcon;
for (const i in tIconMap) {
if(tIconMap[i] === null){
// 解决tIcon的null is not an object问题
console.log(`tIconMap:${i}`);
delete tIconMap[i];
}
}
2022-12-13 09:58:10 +08:00
body = processNewBody(viewReplyType.encode(viewReplyObj).finish());
2022-10-29 11:42:12 +08:00
}
2022-12-13 09:58:10 +08:00
} else if(url.includes("PlayURL/PlayView")){
console.log('PlayURL/PlayView/View');
const playViewReplyType = biliRoot.lookupType("bilibili.app.playurl.PlayViewReply");
let playViewReplyObj = playViewReplyType.decode(unGzipBody);
const oldBackgroundConf = playViewReplyObj.playArc?.backgroundPlayConf;
if(oldBackgroundConf && (!oldBackgroundConf.isSupport || oldBackgroundConf.disabled)){
console.log(`后台播放限制去除`);
playViewReplyObj.playArc.backgroundPlayConf.isSupport = true;
playViewReplyObj.playArc.backgroundPlayConf.disabled = false;
playViewReplyObj.playArc.backgroundPlayConf.extraContent = null;
needProcessFlag = true;
body = processNewBody(playViewReplyType.encode(playViewReplyObj).finish());
} else {
console.log('无需调整后台播放设置');
2022-10-29 11:42:12 +08:00
}
} else {
2022-12-13 09:58:10 +08:00
$notification.post('bilibili-proto', "路径匹配错误:", url);
2022-10-29 11:42:12 +08:00
}
2022-12-13 09:58:10 +08:00
if(needProcessFlag){
2022-10-29 11:42:12 +08:00
console.log(`${body.byteLength}---${body.buffer.byteLength}`);
2022-12-13 09:58:10 +08:00
if(isQuanX){
$done({
bodyBytes: body.buffer.slice(body.byteOffset, body.byteLength + body.byteOffset),
headers
});
2022-10-29 11:42:12 +08:00
} else {
2022-12-13 09:58:10 +08:00
$done({
body,
headers
});
2022-10-29 11:42:12 +08:00
}
} else {
2022-12-13 09:58:10 +08:00
console.log('无需处理');
2022-10-29 11:42:12 +08:00
$done({});
}
2022-12-13 09:58:10 +08:00
function processNewBody(unGzipBody){
const length = unGzipBody.length;
2022-10-29 11:42:12 +08:00
let merge = new Uint8Array(5 + length);
2022-12-13 09:58:10 +08:00
merge.set(intToUint8Array(length), 1);
merge.set(unGzipBody, 5);
2022-10-29 11:42:12 +08:00
return merge;
2022-12-13 09:58:10 +08:00
}
function intToUint8Array (num) {
let arr = new ArrayBuffer(4); // an Int32 takes 4 bytes
let view = new DataView(arr);
view.setUint32(0, num, false); // byteOffset = 0; litteEndian = false
return new Uint8Array(arr);
2022-10-29 11:42:12 +08:00
}