MCPcopy Create free account
hub / github.com/NobyDa/Script / GetCookie

Function GetCookie

KuaiKan-DailyBonus/KKMH.js:174–198  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172}
173
174function GetCookie() {
175 const RA = $.getdata("@KKMH.COOKIE")
176 const TM = $.getdata("@KKMH.TIME")
177 const CK = $request.headers['Cookie'] || $request.headers['cookie'];
178 if (JSON.stringify($request.headers).match(/session=/) && CK) {
179 if (RA != CK) {
180 if ($.setdata(CK, "@KKMH.COOKIE")) {
181 $.setdata(JSON.stringify(Date.now()), "@KKMH.TIME")
182 if (!TM || TM && (Date.now() - TM) / 1000 >= 21600) {
183 $.msg(`${RA?`更新`:`首次写入`}${$.name}Cookie成功 🎉`, "", "", imgUrl)
184 } else if (RA.match(/uid=\d+/)[0] == CK.match(/uid=\d+/)[0]) {
185 $.log(`\n更新${$.name}Cookie成功! 🎉\n检测到频繁通知, 已转为输出日志`)
186 } else {
187 $.msg(`更新${$.name}Cookie成功 🎉`, "", "", imgUrl)
188 }
189 } else {
190 $.msg(`${RA?`更新`:`首次写入`}${$.name}Cookie失败‼️`, "", "", imgUrl)
191 }
192 } else {
193 $.log(`${$.name}-Cookie相同, 跳过写入 ⚠️`)
194 }
195 } else {
196 $.log(`${$.name}-请求不含Cookie, 跳过写入 ‼️`)
197 }
198}
199
200//Bark APP notify
201async function BarkNotify(c,k,t,b){for(let i=0;i<3;i++){console.log(`🔷Bark notify >> Start push (${i+1})`);const s=await new Promise((n)=>{c.post({url:'https://api.day.app/push',headers:{'Content-Type':'application/json'},body:JSON.stringify({title:t,body:b,device_key:k,ext_params:{group:t}})},(e,r,d)=>r&&r.status==200?n(1):n(d||e))});if(s===1){console.log('✅Push success!');break}else{console.log(`❌Push failed! >> ${s.message||s}`)}}}

Callers 1

KKMH.jsFile · 0.70

Calls 5

getdataMethod · 0.45
stringifyMethod · 0.45
setdataMethod · 0.45
msgMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected