diff --git a/js/BiliBili.Redirect.request.beta.js b/js/BiliBili.Redirect.request.beta.js index c99600d..0c03047 100644 --- a/js/BiliBili.Redirect.request.beta.js +++ b/js/BiliBili.Redirect.request.beta.js @@ -763,7 +763,8 @@ var Settings = { Host: { Akamaized: "upos-sz-mirrorali.bilivideo.com", BStar: "upos-sz-mirrorali.bilivideo.com", - PCDN: "upos-sz-mirrorali.bilivideo.com" + PCDN: "upos-sz-mirrorali.bilivideo.com", + MCDN: "proxy-tf-all-ws.bilivideo.com" } }; var BiliBili_Redirect = { @@ -852,7 +853,7 @@ function setENV(name, platforms, database) { return { Settings, Caches, Configs }; } -const $ = new ENV("📺 BiliBili: 🔀 Redirect v0.2.2(1014) request.beta"); +const $ = new ENV("📺 BiliBili: 🔀 Redirect v0.2.3(1015) request.beta"); // 构造回复数据 let $response = undefined; @@ -984,7 +985,7 @@ $.log(`⚠ FORMAT: ${FORMAT}`, ""); case "8082": // MCDN case "9102": // MCDN url.protocol = "https"; - url.hostname = "proxy-tf-all-ws.bilivideo.com"; + url.hostname = Settings.Host.MCDN; url.port = ""; url.pathname = ""; url.searchParams.set("url", $request.url); diff --git a/js/BiliBili.Redirect.request.js b/js/BiliBili.Redirect.request.js index 01e22a7..d3744d6 100644 --- a/js/BiliBili.Redirect.request.js +++ b/js/BiliBili.Redirect.request.js @@ -1 +1 @@ -class e{static name="Lodash";static version="1.2.2";static about(){return console.log(`\n🟧 ${this.name} v${this.version}\n`)}static get(e={},t="",s=void 0){Array.isArray(t)||(t=this.toPath(t));const o=t.reduce(((e,t)=>Object(e)[t]),e);return void 0===o?s:o}static set(e={},t="",s){return Array.isArray(t)||(t=this.toPath(t)),t.slice(0,-1).reduce(((e,s,o)=>Object(e[s])===e[s]?e[s]:e[s]=/^\d+$/.test(t[o+1])?[]:{}),e)[t[t.length-1]]=s,e}static unset(e={},t=""){return Array.isArray(t)||(t=this.toPath(t)),t.reduce(((e,s,o)=>o===t.length-1?(delete e[s],!0):Object(e)[s]),e)}static toPath(e){return e.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean)}static escape(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,(e=>t[e]))}static unescape(e){const t={"&":"&","<":"<",">":">",""":'"',"'":"'"};return e.replace(/&|<|>|"|'/g,(e=>t[e]))}}class t{static name="$Storage";static version="1.0.9";static about(){return console.log(`\n🟧 ${this.name} v${this.version}\n`)}static data=null;static dataFile="box.dat";static#e=/^@(?[^.]+)(?:\.(?.*))?$/;static#t(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":"undefined"!=typeof Egern?"Egern":void 0}static getItem(t=new String,s=null){let o=s;if(!0===t.startsWith("@")){const{key:s,path:a}=t.match(this.#e)?.groups;t=s;let r=this.getItem(t,{});"object"!=typeof r&&(r={}),o=e.get(r,a);try{o=JSON.parse(o)}catch(e){}}else{switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":o=$persistentStore.read(t);break;case"Quantumult X":o=$prefs.valueForKey(t);break;case"Node.js":this.data=this.#s(this.dataFile),o=this.data?.[t];break;default:o=this.data?.[t]||null}try{o=JSON.parse(o)}catch(e){}}return o??s}static setItem(t=new String,s=new String){let o=!1;if("object"==typeof s)s=JSON.stringify(s);else s=String(s);if(!0===t.startsWith("@")){const{key:a,path:r}=t.match(this.#e)?.groups;t=a;let i=this.getItem(t,{});"object"!=typeof i&&(i={}),e.set(i,r,s),o=this.setItem(t,i)}else switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":o=$persistentStore.write(s,t);break;case"Quantumult X":o=$prefs.setValueForKey(s,t);break;case"Node.js":this.data=this.#s(this.dataFile),this.data[t]=s,this.#o(this.dataFile),o=!0;break;default:o=this.data?.[t]||null}return o}static removeItem(t){let s=!1;if(!0===t.startsWith("@")){const{key:o,path:a}=t.match(this.#e)?.groups;t=o;let r=this.getItem(t);"object"!=typeof r&&(r={}),keyValue=e.unset(r,a),s=this.setItem(t,r)}else switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":case"Node.js":default:s=!1;break;case"Quantumult X":s=$prefs.removeValueForKey(t)}return s}static clear(){let e=!1;switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":case"Node.js":default:e=!1;break;case"Quantumult X":e=$prefs.removeAllValues()}return e}static#s(e){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(e),s=this.path.resolve(process.cwd(),e),o=this.fs.existsSync(t),a=!o&&this.fs.existsSync(s);if(!o&&!a)return{};{const e=o?t:s;try{return JSON.parse(this.fs.readFileSync(e))}catch(e){return{}}}}}static#o(e=this.dataFile){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(e),s=this.path.resolve(process.cwd(),e),o=this.fs.existsSync(t),a=!o&&this.fs.existsSync(s),r=JSON.stringify(this.data);o?this.fs.writeFileSync(t,r):a?this.fs.writeFileSync(s,r):this.fs.writeFileSync(t,r)}}}class s{static name="ENV";static version="1.8.3";static about(){return console.log(`\n🟧 ${this.name} v${this.version}\n`)}constructor(e,t){console.log(`\n🟧 ${s.name} v${s.version}\n`),this.name=e,this.logs=[],this.isMute=!1,this.isMuteLog=!1,this.logSeparator="\n",this.encoding="utf-8",this.startTime=(new Date).getTime(),Object.assign(this,t),this.log(`\n🚩 开始!\n${e}\n`)}environment(){switch(this.platform()){case"Surge":return $environment.app="Surge",$environment;case"Stash":return $environment.app="Stash",$environment;case"Egern":return $environment.app="Egern",$environment;case"Loon":let e=$loon.split(" ");return{device:e[0],ios:e[1],"loon-version":e[2],app:"Loon"};case"Quantumult X":return{app:"Quantumult X"};case"Node.js":return process.env.app="Node.js",process.env;default:return{}}}platform(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":"undefined"!=typeof Egern?"Egern":void 0}isNode(){return"Node.js"===this.platform()}isQuanX(){return"Quantumult X"===this.platform()}isSurge(){return"Surge"===this.platform()}isLoon(){return"Loon"===this.platform()}isShadowrocket(){return"Shadowrocket"===this.platform()}isStash(){return"Stash"===this.platform()}isEgern(){return"Egern"===this.platform()}async getScript(e){return await this.fetch(e).then((e=>e.body))}async runScript(e,s){let o=t.getItem("@chavy_boxjs_userCfgs.httpapi");o=o?.replace?.(/\n/g,"")?.trim();let a=t.getItem("@chavy_boxjs_userCfgs.httpapi_timeout");a=1*a??20,a=s?.timeout??a;const[r,i]=o.split("@"),n={url:`http://${i}/v1/scripting/evaluate`,body:{script_text:e,mock_type:"cron",timeout:a},headers:{"X-Key":r,Accept:"*/*"},timeout:a};await this.fetch(n).then((e=>e.body),(e=>this.logErr(e)))}initGotEnv(e){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,e&&(e.headers=e.headers?e.headers:{},void 0===e.headers.Cookie&&void 0===e.cookieJar&&(e.cookieJar=this.ckjar))}async fetch(t={}||"",s={}){switch(t.constructor){case Object:t={...s,...t};break;case String:t={...s,url:t}}t.method||(t.method="GET",(t.body??t.bodyBytes)&&(t.method="POST")),delete t.headers?.Host,delete t.headers?.[":authority"],delete t.headers?.["Content-Length"],delete t.headers?.["content-length"];const o=t.method.toLocaleLowerCase();switch(this.platform()){case"Loon":case"Surge":case"Stash":case"Egern":case"Shadowrocket":default:return t.timeout&&(t.timeout=parseInt(t.timeout,10),this.isSurge()||(t.timeout=1e3*t.timeout)),t.policy&&(this.isLoon()&&(t.node=t.policy),this.isStash()&&e.set(t,"headers.X-Stash-Selected-Proxy",encodeURI(t.policy)),this.isShadowrocket()&&e.set(t,"headers.X-Surge-Proxy",t.policy)),"boolean"==typeof t.redirection&&(t["auto-redirect"]=t.redirection),t.bodyBytes&&!t.body&&(t.body=t.bodyBytes,delete t.bodyBytes),await new Promise(((e,s)=>{$httpClient[o](t,((o,a,r)=>{o?s(o):(a.ok=/^2\d\d$/.test(a.status),a.statusCode=a.status,r&&(a.body=r,1==t["binary-mode"]&&(a.bodyBytes=r)),e(a))}))}));case"Quantumult X":return t.policy&&e.set(t,"opts.policy",t.policy),"boolean"==typeof t["auto-redirect"]&&e.set(t,"opts.redirection",t["auto-redirect"]),t.body instanceof ArrayBuffer?(t.bodyBytes=t.body,delete t.body):ArrayBuffer.isView(t.body)?(t.bodyBytes=t.body.buffer.slice(t.body.byteOffset,t.body.byteLength+t.body.byteOffset),delete object.body):t.body&&delete t.bodyBytes,await $task.fetch(t).then((e=>(e.ok=/^2\d\d$/.test(e.statusCode),e.status=e.statusCode,e)),(e=>Promise.reject(e.error)));case"Node.js":let s=require("iconv-lite");this.initGotEnv(t);const{url:a,...r}=t;return await this.got[o](a,r).on("redirect",((e,t)=>{try{if(e.headers["set-cookie"]){const s=e.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),t.cookieJar=this.ckjar}}catch(e){this.logErr(e)}})).then((e=>(e.statusCode=e.status,e.body=s.decode(e.rawBody,this.encoding),e.bodyBytes=e.rawBody,e)),(e=>Promise.reject(e.message)))}}time(e,t=null){const s=t?new Date(t):new Date;let o={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let t in o)new RegExp("("+t+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?o[t]:("00"+o[t]).substr((""+o[t]).length)));return e}msg(e=name,t="",s="",o){const a=e=>{switch(typeof e){case void 0:return e;case"string":switch(this.platform()){case"Surge":case"Stash":case"Egern":default:return{url:e};case"Loon":case"Shadowrocket":return e;case"Quantumult X":return{"open-url":e};case"Node.js":return}case"object":switch(this.platform()){case"Surge":case"Stash":case"Egern":case"Shadowrocket":default:return{url:e.url||e.openUrl||e["open-url"]};case"Loon":return{openUrl:e.openUrl||e.url||e["open-url"],mediaUrl:e.mediaUrl||e["media-url"]};case"Quantumult X":return{"open-url":e["open-url"]||e.url||e.openUrl,"media-url":e["media-url"]||e.mediaUrl,"update-pasteboard":e["update-pasteboard"]||e.updatePasteboard};case"Node.js":return}default:return}};if(!this.isMute)switch(this.platform()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":default:$notification.post(e,t,s,a(o));break;case"Quantumult X":$notify(e,t,s,a(o));case"Node.js":}if(!this.isMuteLog){let o=["","==============📣系统通知📣=============="];o.push(e),t&&o.push(t),s&&o.push(s),console.log(o.join("\n")),this.logs=this.logs.concat(o)}}log(...e){e.length>0&&(this.logs=[...this.logs,...e]),console.log(e.join(this.logSeparator))}logErr(e){switch(this.platform()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":case"Quantumult X":default:this.log("",`❗️ ${this.name}, 错误!`,e);break;case"Node.js":this.log("",`❗️${this.name}, 错误!`,e.stack)}}wait(e){return new Promise((t=>setTimeout(t,e)))}done(t={}){const s=((new Date).getTime()-this.startTime)/1e3;switch(this.log("",`🚩 ${this.name}, 结束! 🕛 ${s} 秒`,""),this.platform()){case"Surge":t.policy&&e.set(t,"headers.X-Surge-Policy",t.policy),$done(t);break;case"Loon":t.policy&&(t.node=t.policy),$done(t);break;case"Stash":t.policy&&e.set(t,"headers.X-Stash-Selected-Proxy",encodeURI(t.policy)),$done(t);break;case"Egern":case"Shadowrocket":default:$done(t);break;case"Quantumult X":t.policy&&e.set(t,"opts.policy",t.policy),delete t["auto-redirect"],delete t["auto-cookie"],delete t["binary-mode"],delete t.charset,delete t.host,delete t.insecure,delete t.method,delete t.opt,delete t.path,delete t.policy,delete t["policy-descriptor"],delete t.scheme,delete t.sessionIndex,delete t.statusCode,delete t.timeout,t.body instanceof ArrayBuffer?(t.bodyBytes=t.body,delete t.body):ArrayBuffer.isView(t.body)?(t.bodyBytes=t.body.buffer.slice(t.body.byteOffset,t.body.byteLength+t.body.byteOffset),delete t.body):t.body&&delete t.bodyBytes,$done(t);break;case"Node.js":process.exit(1)}}}var o={Switch:!0},a={Settings:o},r={Switch:!0,Host:{Akamaized:"upos-sz-mirrorali.bilivideo.com",BStar:"upos-sz-mirrorali.bilivideo.com",PCDN:"upos-sz-mirrorali.bilivideo.com"}},i={Settings:r},n=Database={Default:Object.freeze({__proto__:null,Settings:o,default:a}),Redirect:Object.freeze({__proto__:null,Settings:r,default:i})};function c(s,o,a){console.log("☑️ Set Environment Variables","");let{Settings:r,Caches:i,Configs:n}=function(s,o,a){let r=t.getItem(s,a),i={};if("undefined"!=typeof $argument&&Boolean($argument)){let t=Object.fromEntries($argument.split("&").map((e=>e.split("=").map((e=>e.replace(/\"/g,""))))));for(let s in t)e.set(i,s,t[s])}const n={Settings:a?.Default?.Settings||{},Configs:a?.Default?.Configs||{},Caches:{}};Array.isArray(o)||(o=[o]);for(let e of o)n.Settings={...n.Settings,...a?.[e]?.Settings,...i,...r?.[e]?.Settings},n.Configs={...n.Configs,...a?.[e]?.Configs},r?.[e]?.Caches&&"string"==typeof r?.[e]?.Caches&&(r[e].Caches=JSON.parse(r?.[e]?.Caches)),n.Caches={...n.Caches,...r?.[e]?.Caches};return function e(t,s){for(var o in t){var a=t[o];t[o]="object"==typeof a&&null!==a?e(a,s):s(o,a)}return t}(n.Settings,((e,t)=>("true"===t||"false"===t?t=JSON.parse(t):"string"==typeof t&&(t=t.includes(",")?t.split(",").map((e=>c(e))):c(t)),t))),n;function c(e){return e&&!isNaN(e)&&(e=parseInt(e,10)),e}}(s,o,a);return console.log(`✅ Set Environment Variables, Settings: ${typeof r}, Settings内容: ${JSON.stringify(r)}`,""),{Settings:r,Caches:i,Configs:n}}const l=new s("📺 BiliBili: 🔀 Redirect v0.2.2(1014) request");let u;const d=new URL($request.url),h=$request.method,p=d.hostname,m=d.pathname;d.pathname.split("/").filter(Boolean),l.log(`⚠ METHOD: ${h}, HOST: ${p}, PATH: ${m}`,"");const g=($request.headers?.["Content-Type"]??$request.headers?.["content-type"])?.split(";")?.[0];(async()=>{const{Settings:e,Caches:t,Configs:s}=c("BiliBili","Redirect",n);switch(e.Switch){case!0:default:switch(h){case"POST":case"PUT":case"PATCH":case"DELETE":switch(g){case void 0:case"application/x-www-form-urlencoded":case"text/plain":default:case"application/x-mpegURL":case"application/x-mpegurl":case"application/vnd.apple.mpegurl":case"audio/mpegurl":case"text/xml":case"text/html":case"text/plist":case"application/xml":case"application/plist":case"application/x-plist":case"text/vtt":case"application/vtt":case"text/json":case"application/json":break;case"application/protobuf":case"application/x-protobuf":case"application/vnd.google.protobuf":case"application/grpc":case"application/grpc+proto":case"application/octet-stream":let e=l.isQuanX()?new Uint8Array($request.bodyBytes??[]):$request.body??new Uint8Array;$request.body=e}case"GET":case"HEAD":case"OPTIONS":case void 0:default:switch(p){case"upos-sz-mirrorali.bilivideo.com":case"upos-sz-mirroralib.bilivideo.com":case"upos-sz-mirroralio1.bilivideo.com":case"upos-sz-mirrorcos.bilivideo.com":case"upos-sz-mirrorcosb.bilivideo.com":case"upos-sz-mirrorcoso1.bilivideo.com":case"upos-sz-mirrorhw.bilivideo.com":case"upos-sz-mirrorhwb.bilivideo.com":case"upos-sz-mirrorhwo1.bilivideo.com":case"upos-sz-mirror08c.bilivideo.com":case"upos-sz-mirror08h.bilivideo.com":case"upos-sz-mirror08ct.bilivideo.com":case"upos-sz-mirroraliov.bilivideo.com":case"upos-sz-mirrorcosov.bilivideo.com":case"upos-sz-mirrorhwov.bilivideo.com":break;case"upos-hz-mirrorakam.akamaized.net":d.hostname=e.Host.Akamaized;break;case"upos-sz-mirroralibstar1.bilivideo.com":case"upos-sz-mirrorcosbstar1.bilivideo.com":case"upos-sz-mirrorhwbstar1.bilivideo.com":case"upos-bstar1-mirrorakam.akamaized.net":d.hostname=e.Host.BStar;break;default:switch(d.port){case"486":const t=d.searchParams.get("cdn"),s=d.searchParams.get("sid");t?(d.hostname=`d1--${t}.bilivideo.com`,d.port=""):s&&(d.hostname=`${s}.bilivideo.com`,d.port="");break;case"4480":d.protocol="http",d.hostname=d.searchParams.get("xy_usource")||e.Host.PCDN,d.port="";break;case"4483":case"8000":case"8082":case"9102":d.protocol="https",d.hostname="proxy-tf-all-ws.bilivideo.com",d.port="",d.pathname="",d.searchParams.set("url",$request.url);break;case"9305":d.protocol="http",d.hostname=d.PATHs.shift(),d.port="",d.pathname=d.PATHs.join("/")}}case"CONNECT":case"TRACE":}$request.headers?.Host&&($request.headers.Host=d.hostname),$request.url=d.toString();case!1:}})().catch((e=>l.logErr(e))).finally((()=>{if(void 0===u)l.done($request);else l.isQuanX()?(u.status||(u.status="HTTP/1.1 200 OK"),delete u.headers?.["Content-Length"],delete u.headers?.["content-length"],delete u.headers?.["Transfer-Encoding"],l.done(u)):l.done({response:u})})); +class e{static name="Lodash";static version="1.2.2";static about(){return console.log(`\n🟧 ${this.name} v${this.version}\n`)}static get(e={},t="",s=void 0){Array.isArray(t)||(t=this.toPath(t));const o=t.reduce(((e,t)=>Object(e)[t]),e);return void 0===o?s:o}static set(e={},t="",s){return Array.isArray(t)||(t=this.toPath(t)),t.slice(0,-1).reduce(((e,s,o)=>Object(e[s])===e[s]?e[s]:e[s]=/^\d+$/.test(t[o+1])?[]:{}),e)[t[t.length-1]]=s,e}static unset(e={},t=""){return Array.isArray(t)||(t=this.toPath(t)),t.reduce(((e,s,o)=>o===t.length-1?(delete e[s],!0):Object(e)[s]),e)}static toPath(e){return e.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean)}static escape(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,(e=>t[e]))}static unescape(e){const t={"&":"&","<":"<",">":">",""":'"',"'":"'"};return e.replace(/&|<|>|"|'/g,(e=>t[e]))}}class t{static name="$Storage";static version="1.0.9";static about(){return console.log(`\n🟧 ${this.name} v${this.version}\n`)}static data=null;static dataFile="box.dat";static#e=/^@(?[^.]+)(?:\.(?.*))?$/;static#t(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":"undefined"!=typeof Egern?"Egern":void 0}static getItem(t=new String,s=null){let o=s;if(!0===t.startsWith("@")){const{key:s,path:a}=t.match(this.#e)?.groups;t=s;let r=this.getItem(t,{});"object"!=typeof r&&(r={}),o=e.get(r,a);try{o=JSON.parse(o)}catch(e){}}else{switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":o=$persistentStore.read(t);break;case"Quantumult X":o=$prefs.valueForKey(t);break;case"Node.js":this.data=this.#s(this.dataFile),o=this.data?.[t];break;default:o=this.data?.[t]||null}try{o=JSON.parse(o)}catch(e){}}return o??s}static setItem(t=new String,s=new String){let o=!1;if("object"==typeof s)s=JSON.stringify(s);else s=String(s);if(!0===t.startsWith("@")){const{key:a,path:r}=t.match(this.#e)?.groups;t=a;let i=this.getItem(t,{});"object"!=typeof i&&(i={}),e.set(i,r,s),o=this.setItem(t,i)}else switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":o=$persistentStore.write(s,t);break;case"Quantumult X":o=$prefs.setValueForKey(s,t);break;case"Node.js":this.data=this.#s(this.dataFile),this.data[t]=s,this.#o(this.dataFile),o=!0;break;default:o=this.data?.[t]||null}return o}static removeItem(t){let s=!1;if(!0===t.startsWith("@")){const{key:o,path:a}=t.match(this.#e)?.groups;t=o;let r=this.getItem(t);"object"!=typeof r&&(r={}),keyValue=e.unset(r,a),s=this.setItem(t,r)}else switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":case"Node.js":default:s=!1;break;case"Quantumult X":s=$prefs.removeValueForKey(t)}return s}static clear(){let e=!1;switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":case"Node.js":default:e=!1;break;case"Quantumult X":e=$prefs.removeAllValues()}return e}static#s(e){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(e),s=this.path.resolve(process.cwd(),e),o=this.fs.existsSync(t),a=!o&&this.fs.existsSync(s);if(!o&&!a)return{};{const e=o?t:s;try{return JSON.parse(this.fs.readFileSync(e))}catch(e){return{}}}}}static#o(e=this.dataFile){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(e),s=this.path.resolve(process.cwd(),e),o=this.fs.existsSync(t),a=!o&&this.fs.existsSync(s),r=JSON.stringify(this.data);o?this.fs.writeFileSync(t,r):a?this.fs.writeFileSync(s,r):this.fs.writeFileSync(t,r)}}}class s{static name="ENV";static version="1.8.3";static about(){return console.log(`\n🟧 ${this.name} v${this.version}\n`)}constructor(e,t){console.log(`\n🟧 ${s.name} v${s.version}\n`),this.name=e,this.logs=[],this.isMute=!1,this.isMuteLog=!1,this.logSeparator="\n",this.encoding="utf-8",this.startTime=(new Date).getTime(),Object.assign(this,t),this.log(`\n🚩 开始!\n${e}\n`)}environment(){switch(this.platform()){case"Surge":return $environment.app="Surge",$environment;case"Stash":return $environment.app="Stash",$environment;case"Egern":return $environment.app="Egern",$environment;case"Loon":let e=$loon.split(" ");return{device:e[0],ios:e[1],"loon-version":e[2],app:"Loon"};case"Quantumult X":return{app:"Quantumult X"};case"Node.js":return process.env.app="Node.js",process.env;default:return{}}}platform(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":"undefined"!=typeof Egern?"Egern":void 0}isNode(){return"Node.js"===this.platform()}isQuanX(){return"Quantumult X"===this.platform()}isSurge(){return"Surge"===this.platform()}isLoon(){return"Loon"===this.platform()}isShadowrocket(){return"Shadowrocket"===this.platform()}isStash(){return"Stash"===this.platform()}isEgern(){return"Egern"===this.platform()}async getScript(e){return await this.fetch(e).then((e=>e.body))}async runScript(e,s){let o=t.getItem("@chavy_boxjs_userCfgs.httpapi");o=o?.replace?.(/\n/g,"")?.trim();let a=t.getItem("@chavy_boxjs_userCfgs.httpapi_timeout");a=1*a??20,a=s?.timeout??a;const[r,i]=o.split("@"),n={url:`http://${i}/v1/scripting/evaluate`,body:{script_text:e,mock_type:"cron",timeout:a},headers:{"X-Key":r,Accept:"*/*"},timeout:a};await this.fetch(n).then((e=>e.body),(e=>this.logErr(e)))}initGotEnv(e){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,e&&(e.headers=e.headers?e.headers:{},void 0===e.headers.Cookie&&void 0===e.cookieJar&&(e.cookieJar=this.ckjar))}async fetch(t={}||"",s={}){switch(t.constructor){case Object:t={...s,...t};break;case String:t={...s,url:t}}t.method||(t.method="GET",(t.body??t.bodyBytes)&&(t.method="POST")),delete t.headers?.Host,delete t.headers?.[":authority"],delete t.headers?.["Content-Length"],delete t.headers?.["content-length"];const o=t.method.toLocaleLowerCase();switch(this.platform()){case"Loon":case"Surge":case"Stash":case"Egern":case"Shadowrocket":default:return t.timeout&&(t.timeout=parseInt(t.timeout,10),this.isSurge()||(t.timeout=1e3*t.timeout)),t.policy&&(this.isLoon()&&(t.node=t.policy),this.isStash()&&e.set(t,"headers.X-Stash-Selected-Proxy",encodeURI(t.policy)),this.isShadowrocket()&&e.set(t,"headers.X-Surge-Proxy",t.policy)),"boolean"==typeof t.redirection&&(t["auto-redirect"]=t.redirection),t.bodyBytes&&!t.body&&(t.body=t.bodyBytes,delete t.bodyBytes),await new Promise(((e,s)=>{$httpClient[o](t,((o,a,r)=>{o?s(o):(a.ok=/^2\d\d$/.test(a.status),a.statusCode=a.status,r&&(a.body=r,1==t["binary-mode"]&&(a.bodyBytes=r)),e(a))}))}));case"Quantumult X":return t.policy&&e.set(t,"opts.policy",t.policy),"boolean"==typeof t["auto-redirect"]&&e.set(t,"opts.redirection",t["auto-redirect"]),t.body instanceof ArrayBuffer?(t.bodyBytes=t.body,delete t.body):ArrayBuffer.isView(t.body)?(t.bodyBytes=t.body.buffer.slice(t.body.byteOffset,t.body.byteLength+t.body.byteOffset),delete object.body):t.body&&delete t.bodyBytes,await $task.fetch(t).then((e=>(e.ok=/^2\d\d$/.test(e.statusCode),e.status=e.statusCode,e)),(e=>Promise.reject(e.error)));case"Node.js":let s=require("iconv-lite");this.initGotEnv(t);const{url:a,...r}=t;return await this.got[o](a,r).on("redirect",((e,t)=>{try{if(e.headers["set-cookie"]){const s=e.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),t.cookieJar=this.ckjar}}catch(e){this.logErr(e)}})).then((e=>(e.statusCode=e.status,e.body=s.decode(e.rawBody,this.encoding),e.bodyBytes=e.rawBody,e)),(e=>Promise.reject(e.message)))}}time(e,t=null){const s=t?new Date(t):new Date;let o={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let t in o)new RegExp("("+t+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?o[t]:("00"+o[t]).substr((""+o[t]).length)));return e}msg(e=name,t="",s="",o){const a=e=>{switch(typeof e){case void 0:return e;case"string":switch(this.platform()){case"Surge":case"Stash":case"Egern":default:return{url:e};case"Loon":case"Shadowrocket":return e;case"Quantumult X":return{"open-url":e};case"Node.js":return}case"object":switch(this.platform()){case"Surge":case"Stash":case"Egern":case"Shadowrocket":default:return{url:e.url||e.openUrl||e["open-url"]};case"Loon":return{openUrl:e.openUrl||e.url||e["open-url"],mediaUrl:e.mediaUrl||e["media-url"]};case"Quantumult X":return{"open-url":e["open-url"]||e.url||e.openUrl,"media-url":e["media-url"]||e.mediaUrl,"update-pasteboard":e["update-pasteboard"]||e.updatePasteboard};case"Node.js":return}default:return}};if(!this.isMute)switch(this.platform()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":default:$notification.post(e,t,s,a(o));break;case"Quantumult X":$notify(e,t,s,a(o));case"Node.js":}if(!this.isMuteLog){let o=["","==============📣系统通知📣=============="];o.push(e),t&&o.push(t),s&&o.push(s),console.log(o.join("\n")),this.logs=this.logs.concat(o)}}log(...e){e.length>0&&(this.logs=[...this.logs,...e]),console.log(e.join(this.logSeparator))}logErr(e){switch(this.platform()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":case"Quantumult X":default:this.log("",`❗️ ${this.name}, 错误!`,e);break;case"Node.js":this.log("",`❗️${this.name}, 错误!`,e.stack)}}wait(e){return new Promise((t=>setTimeout(t,e)))}done(t={}){const s=((new Date).getTime()-this.startTime)/1e3;switch(this.log("",`🚩 ${this.name}, 结束! 🕛 ${s} 秒`,""),this.platform()){case"Surge":t.policy&&e.set(t,"headers.X-Surge-Policy",t.policy),$done(t);break;case"Loon":t.policy&&(t.node=t.policy),$done(t);break;case"Stash":t.policy&&e.set(t,"headers.X-Stash-Selected-Proxy",encodeURI(t.policy)),$done(t);break;case"Egern":case"Shadowrocket":default:$done(t);break;case"Quantumult X":t.policy&&e.set(t,"opts.policy",t.policy),delete t["auto-redirect"],delete t["auto-cookie"],delete t["binary-mode"],delete t.charset,delete t.host,delete t.insecure,delete t.method,delete t.opt,delete t.path,delete t.policy,delete t["policy-descriptor"],delete t.scheme,delete t.sessionIndex,delete t.statusCode,delete t.timeout,t.body instanceof ArrayBuffer?(t.bodyBytes=t.body,delete t.body):ArrayBuffer.isView(t.body)?(t.bodyBytes=t.body.buffer.slice(t.body.byteOffset,t.body.byteLength+t.body.byteOffset),delete t.body):t.body&&delete t.bodyBytes,$done(t);break;case"Node.js":process.exit(1)}}}var o={Switch:!0},a={Settings:o},r={Switch:!0,Host:{Akamaized:"upos-sz-mirrorali.bilivideo.com",BStar:"upos-sz-mirrorali.bilivideo.com",PCDN:"upos-sz-mirrorali.bilivideo.com",MCDN:"proxy-tf-all-ws.bilivideo.com"}},i={Settings:r},n=Database={Default:Object.freeze({__proto__:null,Settings:o,default:a}),Redirect:Object.freeze({__proto__:null,Settings:r,default:i})};function c(s,o,a){console.log("☑️ Set Environment Variables","");let{Settings:r,Caches:i,Configs:n}=function(s,o,a){let r=t.getItem(s,a),i={};if("undefined"!=typeof $argument&&Boolean($argument)){let t=Object.fromEntries($argument.split("&").map((e=>e.split("=").map((e=>e.replace(/\"/g,""))))));for(let s in t)e.set(i,s,t[s])}const n={Settings:a?.Default?.Settings||{},Configs:a?.Default?.Configs||{},Caches:{}};Array.isArray(o)||(o=[o]);for(let e of o)n.Settings={...n.Settings,...a?.[e]?.Settings,...i,...r?.[e]?.Settings},n.Configs={...n.Configs,...a?.[e]?.Configs},r?.[e]?.Caches&&"string"==typeof r?.[e]?.Caches&&(r[e].Caches=JSON.parse(r?.[e]?.Caches)),n.Caches={...n.Caches,...r?.[e]?.Caches};return function e(t,s){for(var o in t){var a=t[o];t[o]="object"==typeof a&&null!==a?e(a,s):s(o,a)}return t}(n.Settings,((e,t)=>("true"===t||"false"===t?t=JSON.parse(t):"string"==typeof t&&(t=t.includes(",")?t.split(",").map((e=>c(e))):c(t)),t))),n;function c(e){return e&&!isNaN(e)&&(e=parseInt(e,10)),e}}(s,o,a);return console.log(`✅ Set Environment Variables, Settings: ${typeof r}, Settings内容: ${JSON.stringify(r)}`,""),{Settings:r,Caches:i,Configs:n}}const l=new s("📺 BiliBili: 🔀 Redirect v0.2.3(1015) request");let u;const d=new URL($request.url),h=$request.method,p=d.hostname,m=d.pathname;d.pathname.split("/").filter(Boolean),l.log(`⚠ METHOD: ${h}, HOST: ${p}, PATH: ${m}`,"");const g=($request.headers?.["Content-Type"]??$request.headers?.["content-type"])?.split(";")?.[0];(async()=>{const{Settings:e,Caches:t,Configs:s}=c("BiliBili","Redirect",n);switch(e.Switch){case!0:default:switch(h){case"POST":case"PUT":case"PATCH":case"DELETE":switch(g){case void 0:case"application/x-www-form-urlencoded":case"text/plain":default:case"application/x-mpegURL":case"application/x-mpegurl":case"application/vnd.apple.mpegurl":case"audio/mpegurl":case"text/xml":case"text/html":case"text/plist":case"application/xml":case"application/plist":case"application/x-plist":case"text/vtt":case"application/vtt":case"text/json":case"application/json":break;case"application/protobuf":case"application/x-protobuf":case"application/vnd.google.protobuf":case"application/grpc":case"application/grpc+proto":case"application/octet-stream":let e=l.isQuanX()?new Uint8Array($request.bodyBytes??[]):$request.body??new Uint8Array;$request.body=e}case"GET":case"HEAD":case"OPTIONS":case void 0:default:switch(p){case"upos-sz-mirrorali.bilivideo.com":case"upos-sz-mirroralib.bilivideo.com":case"upos-sz-mirroralio1.bilivideo.com":case"upos-sz-mirrorcos.bilivideo.com":case"upos-sz-mirrorcosb.bilivideo.com":case"upos-sz-mirrorcoso1.bilivideo.com":case"upos-sz-mirrorhw.bilivideo.com":case"upos-sz-mirrorhwb.bilivideo.com":case"upos-sz-mirrorhwo1.bilivideo.com":case"upos-sz-mirror08c.bilivideo.com":case"upos-sz-mirror08h.bilivideo.com":case"upos-sz-mirror08ct.bilivideo.com":case"upos-sz-mirroraliov.bilivideo.com":case"upos-sz-mirrorcosov.bilivideo.com":case"upos-sz-mirrorhwov.bilivideo.com":break;case"upos-hz-mirrorakam.akamaized.net":d.hostname=e.Host.Akamaized;break;case"upos-sz-mirroralibstar1.bilivideo.com":case"upos-sz-mirrorcosbstar1.bilivideo.com":case"upos-sz-mirrorhwbstar1.bilivideo.com":case"upos-bstar1-mirrorakam.akamaized.net":d.hostname=e.Host.BStar;break;default:switch(d.port){case"486":const t=d.searchParams.get("cdn"),s=d.searchParams.get("sid");t?(d.hostname=`d1--${t}.bilivideo.com`,d.port=""):s&&(d.hostname=`${s}.bilivideo.com`,d.port="");break;case"4480":d.protocol="http",d.hostname=d.searchParams.get("xy_usource")||e.Host.PCDN,d.port="";break;case"4483":case"8000":case"8082":case"9102":d.protocol="https",d.hostname=e.Host.MCDN,d.port="",d.pathname="",d.searchParams.set("url",$request.url);break;case"9305":d.protocol="http",d.hostname=d.PATHs.shift(),d.port="",d.pathname=d.PATHs.join("/")}}case"CONNECT":case"TRACE":}$request.headers?.Host&&($request.headers.Host=d.hostname),$request.url=d.toString();case!1:}})().catch((e=>l.logErr(e))).finally((()=>{if(void 0===u)l.done($request);else l.isQuanX()?(u.status||(u.status="HTTP/1.1 200 OK"),delete u.headers?.["Content-Length"],delete u.headers?.["content-length"],delete u.headers?.["Transfer-Encoding"],l.done(u)):l.done({response:u})})); diff --git a/js/BiliBili.Redirect.response.beta.js b/js/BiliBili.Redirect.response.beta.js index 1ea7eb6..916af3c 100644 --- a/js/BiliBili.Redirect.response.beta.js +++ b/js/BiliBili.Redirect.response.beta.js @@ -763,7 +763,8 @@ var Settings = { Host: { Akamaized: "upos-sz-mirrorali.bilivideo.com", BStar: "upos-sz-mirrorali.bilivideo.com", - PCDN: "upos-sz-mirrorali.bilivideo.com" + PCDN: "upos-sz-mirrorali.bilivideo.com", + MCDN: "proxy-tf-all-ws.bilivideo.com" } }; var BiliBili_Redirect = { diff --git a/modules/BiliBili.Redirect.beta.sgmodule b/modules/BiliBili.Redirect.beta.sgmodule index 53a03a7..1de1840 100644 --- a/modules/BiliBili.Redirect.beta.sgmodule +++ b/modules/BiliBili.Redirect.beta.sgmodule @@ -6,8 +6,8 @@ #!manual=https://manual.biliuniverse.io #!icon=https://github.com/BiliUniverse/Redirect/raw/main/src/assets/icon_rounded_108x.png #!category=📺 BiliUniverse -#!arguments=Host.Akamaized:upos-sz-mirrorali.bilivideo.com,Host.BStar:upos-sz-mirrorali.bilivideo.com,Host.PCDN:upos-sz-mirrorali.bilivideo.com -#!arguments-desc=Host.Akamaized: 重定向港澳台 CDN 主机名\nHost.BStar: 重定向国际版 CDN 主机名\nHost.PCDN: 重定向 PCDN 主机名 +#!arguments=Host.Akamaized:upos-sz-mirrorali.bilivideo.com,Host.BStar:upos-sz-mirrorali.bilivideo.com,Host.PCDN:upos-sz-mirrorali.bilivideo.com,Host.MCDN:proxy-tf-all-ws.bilivideo.com +#!arguments-desc=Host.Akamaized: 重定向港澳台 CDN 主机名\nHost.BStar: 重定向国际版 CDN 主机名\nHost.PCDN: 重定向 PCDN 主机名\nHost.MCDN: 重定向 MCDN 主机名 [General] # > TCP Force HTTP Hosts @@ -17,8 +17,8 @@ force-http-engine-hosts = %APPEND% *.mcdn.bilivideo.cn:486, *:4480, *.mcdn.biliv [Script] BiliBili.Redirect.CDN.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/.+\.bilivideo\.com\/upgcxcode\/, engine=webview, debug=1, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/beta/js/BiliBili.Redirect.request.beta.js, argument= BiliBili.Redirect.MCDN.live-bvc.m4s = type=http-request, pattern=^https?:\/\/[xy0-9]+\.mcdn\.bilivideo\.cn:486\/live-bvc\/, engine=webview, debug=1, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/beta/js/BiliBili.Redirect.request.beta.js, argument= -BiliBili.Redirect.MCDN.v1.resource.m4s = type=http-request, pattern=^https?:\/\/(.+):(8000|8082)\/v1\/resource\/, engine=webview, debug=1, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/beta/js/BiliBili.Redirect.request.beta.js, argument= -BiliBili.Redirect.MCDN.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/[xy0-9]+\.mcdn\.bilivideo\.cn:(4483|9102)\/upgcxcode\/, engine=webview, debug=1, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/beta/js/BiliBili.Redirect.request.beta.js, argument= +BiliBili.Redirect.MCDN.v1.resource.m4s = type=http-request, pattern=^https?:\/\/(.+):(8000|8082)\/v1\/resource\/, engine=webview, debug=1, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/beta/js/BiliBili.Redirect.request.beta.js, argument=Host.MCDN={{{Host.MCDN}}} +BiliBili.Redirect.MCDN.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/[xy0-9]+\.mcdn\.bilivideo\.cn:(4483|9102)\/upgcxcode\/, engine=webview, debug=1, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/beta/js/BiliBili.Redirect.request.beta.js, argument=Host.MCDN={{{Host.MCDN}}} BiliBili.Redirect.PCDN.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/(.+):4480\/upgcxcode\/, engine=webview, debug=1, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/beta/js/BiliBili.Redirect.request.beta.js, argument=Host.PCDN={{{Host.PCDN}}} BiliBili.Redirect.PCDN.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/(.+)\.v1d\.szbdyd\.com:9305\/([^/]+)\/upgcxcode\/, engine=webview, debug=1, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/beta/js/BiliBili.Redirect.request.beta.js, argument=Host.PCDN={{{Host.PCDN}}} BiliBili.Redirect.Akamaized.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/upos-(hz|bstar1)-mirrorakam\.akamaized\.net\/upgcxcode\/, engine=webview, debug=1, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/beta/js/BiliBili.Redirect.request.beta.js, argument=Host.Akamaized={{{Host.Akamaized}}} diff --git a/modules/BiliBili.Redirect.sgmodule b/modules/BiliBili.Redirect.sgmodule index 56e3bbb..17d41f4 100644 --- a/modules/BiliBili.Redirect.sgmodule +++ b/modules/BiliBili.Redirect.sgmodule @@ -6,8 +6,8 @@ #!manual=https://manual.biliuniverse.io #!icon=https://github.com/BiliUniverse/Redirect/raw/main/src/assets/icon_rounded_108x.png #!category=📺 BiliUniverse -#!arguments=Host.Akamaized:upos-sz-mirrorali.bilivideo.com,Host.BStar:upos-sz-mirrorali.bilivideo.com,Host.PCDN:upos-sz-mirrorali.bilivideo.com -#!arguments-desc=Host.Akamaized: 重定向港澳台 CDN 主机名\nHost.BStar: 重定向国际版 CDN 主机名\nHost.PCDN: 重定向 PCDN 主机名 +#!arguments=Host.Akamaized:upos-sz-mirrorali.bilivideo.com,Host.BStar:upos-sz-mirrorali.bilivideo.com,Host.PCDN:upos-sz-mirrorali.bilivideo.com,Host.MCDN:proxy-tf-all-ws.bilivideo.com +#!arguments-desc=Host.Akamaized: 重定向港澳台 CDN 主机名\nHost.BStar: 重定向国际版 CDN 主机名\nHost.PCDN: 重定向 PCDN 主机名\nHost.MCDN: 重定向 MCDN 主机名 [General] # > TCP Force HTTP Hosts @@ -16,8 +16,8 @@ force-http-engine-hosts = %APPEND% *:4480, *.mcdn.bilivideo.cn:4483, *:8000, *:8 [Script] BiliBili.Redirect.CDN.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/.+\.bilivideo\.com\/upgcxcode\/, engine=webview, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/main/js/BiliBili.Redirect.request.js, argument= -BiliBili.Redirect.MCDN.v1.resource.m4s = type=http-request, pattern=^https?:\/\/(.+):(8000|8082)\/v1\/resource\/, engine=webview, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/main/js/BiliBili.Redirect.request.js, argument= -BiliBili.Redirect.MCDN.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/[xy0-9]+\.mcdn\.bilivideo\.(cn|com):(4483|9102)\/upgcxcode\/, engine=webview, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/main/js/BiliBili.Redirect.request.js, argument= +BiliBili.Redirect.MCDN.v1.resource.m4s = type=http-request, pattern=^https?:\/\/(.+):(8000|8082)\/v1\/resource\/, engine=webview, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/main/js/BiliBili.Redirect.request.js, argument=Host.MCDN={{{Host.MCDN}}} +BiliBili.Redirect.MCDN.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/[xy0-9]+\.mcdn\.bilivideo\.(cn|com):(4483|9102)\/upgcxcode\/, engine=webview, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/main/js/BiliBili.Redirect.request.js, argument=Host.MCDN={{{Host.MCDN}}} BiliBili.Redirect.PCDN.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/(.+):4480\/upgcxcode\/, engine=webview, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/main/js/BiliBili.Redirect.request.js, argument=Host.PCDN={{{Host.PCDN}}} BiliBili.Redirect.Akamaized.upgcxcode.m4s = type=http-request, pattern=^https?:\/\/upos-(hz|bstar1)-mirrorakam\.akamaized\.net/upgcxcode\/, engine=webview, script-path=https://raw.githubusercontent.com/BiliUniverse/Redirect/main/js/BiliBili.Redirect.request.js, argument=Host.Akamaized={{{Host.Akamaized}}} diff --git a/src/BiliBili.Redirect.request.beta.js b/src/BiliBili.Redirect.request.beta.js index 4b69223..919be56 100644 --- a/src/BiliBili.Redirect.request.beta.js +++ b/src/BiliBili.Redirect.request.beta.js @@ -5,7 +5,7 @@ import ENV from "./ENV/ENV.mjs"; import Database from "./database/BiliBili.mjs"; import setENV from "./function/setENV.mjs"; -const $ = new ENV("📺 BiliBili: 🔀 Redirect v0.2.2(1014) request.beta"); +const $ = new ENV("📺 BiliBili: 🔀 Redirect v0.2.3(1015) request.beta"); // 构造回复数据 let $response = undefined; @@ -151,7 +151,7 @@ $.log(`⚠ FORMAT: ${FORMAT}`, ""); case "8082": // MCDN case "9102": // MCDN url.protocol = "https"; - url.hostname = "proxy-tf-all-ws.bilivideo.com" + url.hostname = Settings.Host.MCDN; url.port = ""; url.pathname = ""; url.searchParams.set("url", $request.url); diff --git a/src/BiliBili.Redirect.request.js b/src/BiliBili.Redirect.request.js index 4bf274d..213943f 100644 --- a/src/BiliBili.Redirect.request.js +++ b/src/BiliBili.Redirect.request.js @@ -5,7 +5,7 @@ import ENV from "./ENV/ENV.mjs"; import Database from "./database/BiliBili.mjs"; import setENV from "./function/setENV.mjs"; -const $ = new ENV("📺 BiliBili: 🔀 Redirect v0.2.2(1014) request"); +const $ = new ENV("📺 BiliBili: 🔀 Redirect v0.2.3(1015) request"); // 构造回复数据 let $response = undefined; @@ -151,7 +151,7 @@ const FORMAT = ($request.headers?.["Content-Type"] ?? $request.headers?.["conten case "8082": // MCDN case "9102": // MCDN url.protocol = "https"; - url.hostname = "proxy-tf-all-ws.bilivideo.com" + url.hostname = Settings.Host.MCDN; url.port = ""; url.pathname = ""; url.searchParams.set("url", $request.url); diff --git a/src/database/BiliBili.Redirect.json b/src/database/BiliBili.Redirect.json index dc8235a..15993a1 100644 --- a/src/database/BiliBili.Redirect.json +++ b/src/database/BiliBili.Redirect.json @@ -4,7 +4,8 @@ "Host": { "Akamaized": "upos-sz-mirrorali.bilivideo.com", "BStar": "upos-sz-mirrorali.bilivideo.com", - "PCDN": "upos-sz-mirrorali.bilivideo.com" + "PCDN": "upos-sz-mirrorali.bilivideo.com", + "MCDN": "proxy-tf-all-ws.bilivideo.com" } } }