MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / getActivityToken

Method getActivityToken

daily/yht.js:89–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87 ObjectKeys2LowerCase(e) { return e = Object.fromEntries(Object.entries(e).map((([e, t]) => [e.toLowerCase(), t]))), new Proxy(e, { get: function (e, t, r) { return Reflect.get(e, t.toLowerCase(), r) }, set: function (e, t, r, n) { return Reflect.set(e, t.toLowerCase(), r, n) } }) }
88
89 async getActivityToken() {
90
91
92 const opts = {
93 method: "GET",
94 url: this.activityUrl,
95 maxRedirects: 0,
96 // 关键点 2: 默认 Axios 认为非 2xx 是错误,需定义 302 为合法状态
97 validateStatus: function (status) {
98 return status >= 200 && status < 400; // 允许 302 (或 3xx) 进入 .then
99 },
100 headers: {}
101 }
102 let res = await axios.request(opts);
103
104 let headers = this.ObjectKeys2LowerCase(res?.headers);
105 //对青龙进行兼容
106 let session = Array.isArray(headers['set-cookie']) ? [...new Set(headers['set-cookie'])].join("") : headers['set-cookie'];
107
108 let [wdata4, w_ts, _ac, wdata3, dcustom] = session.match(/(wdata4|w_ts|_ac|wdata3|dcustom)=.+?;/g)
109 this.session = wdata4 + w_ts + _ac + wdata3 + dcustom;
110 $.log(`✅ 获取活动token成功!`)
111
112
113
114 }
115 async getActivityKey() {
116
117 let options = {

Callers 1

runMethod · 0.95

Calls 3

ObjectKeys2LowerCaseMethod · 0.95
requestMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected