diff --git a/Scripts/SignIn/Bilibili/BiliBili_NobyDa.js b/Scripts/SignIn/Bilibili/BiliBili_NobyDa.js deleted file mode 100644 index 40ec4e5..0000000 --- a/Scripts/SignIn/Bilibili/BiliBili_NobyDa.js +++ /dev/null @@ -1,144 +0,0 @@ -/* -哔哩哔哩漫画签到 - -脚本兼容: QuantumultX, Surge, Loon -电报频道:@NobyDa -问题反馈:@NobyDa_bot -如果转载,请注明出处 - -说明: -打开哔哩哔哩漫画后 (AppStore中国区),单击"我的", 如果通知获取cookie成功, 则可以使用此脚本. - -脚本将在每天上午9点执行。 您可以修改执行时间。 - -~~~~~~~~~~~~~~~~ -Surge 4.2.0+ : - -[Script] -Bili漫画签到 = type=cron,cronexp=0 9 * * *,wake-system=1,script-path=https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js - -Bili漫画Cookie = type=http-request,pattern=^https:\/\/passport\.biligame\.com\/api\/login\/sso.+?version%22%3A%22(3|4|5),script-path=https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js - -[MITM] -hostname = passport.biligame.com -~~~~~~~~~~~~~~~~ -QX 1.0.10+ : - -[task_local] -0 9 * * * https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js, tag=Bili漫画签到 - -[rewrite_local] -#获取Bili漫画Cookie -^https:\/\/passport\.biligame\.com\/api\/login\/sso.+?version%22%3A%22(3|4|5) url script-request-header https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js - -[mitm] -hostname = passport.biligame.com -~~~~~~~~~~~~~~~~ -*/ - - -const $nobyda = nobyda(); - -if ($nobyda.isRequest) { - GetCookie() -} else { - checkin() -} - -function checkin() { - const bilibili = { - url: 'https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn', - headers: { - Cookie: $nobyda.read("CookieBM"), - }, - body: "platform=ios" - }; - $nobyda.post(bilibili, function (error, response, data) { - if (!error) { - if (parseInt(response.status) == 200) { - console.log("bilibili success response : \n" + data) - $nobyda.notify("哔哩哔哩漫画 - 签到成功!🎉", "", "") - } else { - console.log("bilibili failed response : \n" + data) - if (data.match(/duplicate/)) { - $nobyda.notify("哔哩哔哩漫画 - 今日已签过 ⚠️", "", "") - } else if (data.match(/uid must/)) { - $nobyda.notify("哔哩哔哩漫画 - Cookie无效 ‼️‼️", "", "") - } else { - $nobyda.notify("哔哩哔哩漫画 - 签到失败 ‼️", "", data) - } - } - } else { - $nobyda.notify("哔哩哔哩漫画 - 签到接口请求失败", "", error) - } - $nobyda.end() - }) -} - -function GetCookie() { - var CookieName = "B站漫画"; - var CookieKey = "CookieBM"; - var regex = /SESSDATA=.+?;/; - if ($request.headers) { - var header = $request.headers['Cookie'] ? $request.headers['Cookie'] : ""; - if (header.indexOf("SESSDATA=") != -1) { - var CookieValue = regex.exec(header)[0]; - if ($nobyda.read(CookieKey)) { - if ($nobyda.read(CookieKey) != CookieValue) { - var cookie = $nobyda.write(CookieValue, CookieKey); - if (!cookie) { - $nobyda.notify("更新" + CookieName + "Cookie失败‼️", "", ""); - } else { - $nobyda.notify("更新" + CookieName + "Cookie成功 🎉", "", ""); - } - } - } else { - var cookie = $nobyda.write(CookieValue, CookieKey); - if (!cookie) { - $nobyda.notify("首次写入" + CookieName + "Cookie失败‼️", "", ""); - } else { - $nobyda.notify("首次写入" + CookieName + "Cookie成功 🎉", "", ""); - } - } - } else { - $nobyda.notify("写入" + CookieName + "Cookie失败‼️", "", "Cookie关键值缺失"); - } - } else { - $nobyda.notify("写入" + CookieName + "Cookie失败‼️", "", "配置错误, 无法读取请求头,"); - } - $nobyda.end() -} - -function nobyda() { - const isRequest = typeof $request != "undefined" - const isSurge = typeof $httpClient != "undefined" - const isQuanX = typeof $task != "undefined" - const notify = (title, subtitle, message) => { - if (isQuanX) $notify(title, subtitle, message) - if (isSurge) $notification.post(title, subtitle, message) - } - const write = (value, key) => { - if (isQuanX) return $prefs.setValueForKey(value, key) - if (isSurge) return $persistentStore.write(value, key) - } - const read = (key) => { - if (isQuanX) return $prefs.valueForKey(key) - if (isSurge) return $persistentStore.read(key) - } - const post = (options, callback) => { - if (isQuanX) { - if (typeof options == "string") options = {url: options} - options["method"] = "POST" - $task.fetch(options).then(response => { - response["status"] = response.statusCode - callback(null, response, response.body) - }, reason => callback(reason.error, null, null)) - } - if (isSurge) $httpClient.post(options, callback) - } - const end = () => { - if (isQuanX) return $done({}) - if (isSurge) isRequest ? $done({}) : $done() - } - return {isRequest, isQuanX, isSurge, notify, write, read, post, end} -}; \ No newline at end of file diff --git a/Scripts/SignIn/Bilibili/ExchangePoint.js b/Scripts/SignIn/Bilibili/ExchangePoint.js new file mode 100644 index 0000000..475ee51 --- /dev/null +++ b/Scripts/SignIn/Bilibili/ExchangePoint.js @@ -0,0 +1,240 @@ +/* +哔哩哔哩漫画, 积分商城自动抢购脚本 + +脚本兼容: Surge, QuantumultX, Loon + +************************* +【 抢购脚本注意事项 】: +************************* + +该脚本需要使用签到脚本获取Cookie后方可使用. +默认兑换积分商城中的"积分兑换", 兑换数量为用户积分可兑换的最大值 (可于BoxJs内修改) +默认执行时间为中午12:00:10、12:00:20、12:00:30 + +BoxJs订阅地址: https://raw.githubusercontent.com/NobyDa/Script/master/NobyDa_BoxJs.json + +************************* +【 Surge & Loon 脚本配置 】: +************************* + +[Script] +cron "10,20,30 0 12 * * *" script-path=https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/ExchangePoints.js, wake-system=1, timeout=60 + +************************* +【 QX 1.0.10+ 脚本配置 】 : +************************* + +[task_local] +10,20,30 0 12 * * * https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/ExchangePoints.js, tag=哔哩哔哩漫画抢券, enabled=true + +*/ + +// 新建一个实例对象, 把兼容函数定义到$中, 以便统一调用 +let $ = new nobyda(); + +// 读取兑换商品名, 默认兑换积分商城中的"积分兑换"; 该接口为BoxJs预留, 以便修改 +let productName = $.read('BM_ProductName') || '积分兑换'; + +// 读取兑换数量, 默认兑换最大值; 该接口为BoxJs预留, 以便修改 +let productNum = $.read('BM_ProductNum'); + +// 读取循环抢购次数, 默认100次; 该接口为BoxJs预留, 以便修改 +let exchangeNum = $.read('BM_ExchangeNum') || '100'; + +// 读取哔哩哔哩漫画签到脚本所使用的Cookie +let cookie = $.read('CookieBM'); + +// 预留的空对象, 便于函数之间读取数据 +let user = {}; + +(async function() { // 立即运行的匿名异步函数 + // 使用await关键字声明, 表示以同步方式执行异步函数, 可以简单理解为顺序执行 + await Promise.all([ //该方法用于将多个实例包装成一个新的实例, 可以简单理解为同时调用函数, 以进一步提高执行速度 + GetUserPoint(), //查询积分函数 + ListProduct() //查询商品函数 + ]); + await ExchangeProduct(); //上面的查询都完成后, 则执行抢购 + $.done(); //抢购完成后调用Surge、QX内部特有的函数, 用于退出脚本执行 +})(); + +function GetUserPoint() { + const pointUrl = { //查询积分接口 + url: 'https://manga.bilibili.com/twirp/pointshop.v1.Pointshop/GetUserPoint', + headers: { //请求头 + 'Cookie': cookie //用户鉴权Cookie + } + } + return new Promise((resolve) => { //主函数返回Promise实例对象, 以便后续调用时可以实现顺序执行异步函数 + $.post(pointUrl, (error, resp, data) => { //使用post请求查询, 再使用回调函数处理返回的结果 + try { //使用try方法捕获可能出现的代码异常 + if (error) { + throw new Error(error); //如果请求失败, 例如无法联网, 则抛出一个异常 + } else { + const body = JSON.parse(data); //解析响应体json并转化为对象 + if (body.code == 0 && body.data) { //如果响应体为预期格式 + user.point = parseInt(body.data.point); //把查询的积分赋值到全局变量user中 + console.log(`\n当前积分: ${body.data.point}`); //打印日志 + } else { //否则抛出一个异常 + throw new Error(body.msg || data); + } + } + } catch (e) { //接住try代码块中抛出的异常, 并打印日志 + console.log(`\n查询积分: 失败\n出现错误: ${e.message}`); + } finally { //finally语句在try和catch之后无论有无异常都会执行 + resolve(); //异步操作成功时调用, 将Promise对象的状态标记为"成功", 表示已完成查询积分 + } + }) + }) +} + +function ListProduct() { + const listUrl = { //查询商品接口 + url: 'https://manga.bilibili.com/twirp/pointshop.v1.Pointshop/ListProduct', + headers: {} + } + return new Promise((resolve) => { //主函数返回Promise实例对象, 以便后续调用时可以实现顺序执行异步函数 + $.post(listUrl, (error, resp, data) => { //使用post请求查询, 再使用回调函数处理返回的结果 + try { //使用try方法捕获可能出现的代码异常 + if (error) { + throw new Error(error); //如果请求失败, 例如无法联网, 则抛出一个异常 + } else { + const body = JSON.parse(data); //解析响应体json并转化为对象 + if (body.code == 0 && body.data.length >= 1) { //如果接口正常返回商品信息 + // 按全局变量所填写的商品名进行过滤, 并把商品信息赋值到全局变量user中 + user.list = body.data.filter(t => t.title == productName).pop(); + if (!user.list) { + throw new Error('请检查商品名'); //如果填错商品名则抛出一个异常 + } else { //否则打印日志 + console.log(`\n查询商品: ${productName}\n商品库存: ${user.list.remain_amount}`) + } + } else { //否则抛出一个异常 + throw new Error('无商品列表'); + } + } + } catch (e) { //接住try代码块中抛出的异常并打印日志 + console.log(`\n查询商品: ${productName}\n出现错误: ${e.message}`); + } finally { //finally语句在try和catch之后无论有无异常都会执行 + resolve(); //异步操作成功时调用, 将Promise对象的状态标记为"成功", 表示已完成查询商品 + } + }) + }) +} + +function ExchangeProduct() { + return new Promise(async (resolve) => { //主函数返回Promise实例对象, 以便后续调用时可以实现顺序执行异步函数, 该实例函数带有async关键字, 表示里面有异步操作, 例如可使用await得到异步结果 + if (user.list && user.list.remain_amount && user.point >= 100) { //如果商品有库存并且用户积分大于100则进行抢购 + //兑换商品数量(用户积分 除与 商品单价得到兑换数量), 并转成整数; 默认兑换最大数量 + const num = parseInt(productNum || (user.point / user.list.real_cost)); + const exchangeUrl = { + url: 'https://manga.bilibili.com/twirp/pointshop.v1.Pointshop/Exchange', //兑换商品接口 + headers: { //请求头 + 'Content-Type': 'application/json', //声明请求体数据格式 + 'Cookie': cookie //用户鉴权Cookie + }, + body: JSON.stringify({ //请求体转成字符串类型 + product_id: user.list.id, //兑换的商品id + product_num: num, //兑换的商品数量 + point: num * user.list.real_cost //消耗的积分总数 (兑换数量乘单价得到积分总数) + }) + }; + for (let i = 0; i < parseInt(exchangeNum); i++) { //根据全局变量定义的次数, 暴力循环抢购 + // 循环内调用另一个抢购函数, 并传入请求、第几次循环、兑换数量等参数, + // 使用await关键字声明, 表示需要等待每一次的执行结果 + const run = await startExchange(exchangeUrl, i, num); + if (run) { + break; //如果函数返回布尔值true, 则跳出循环, 脚本结束 + } + } + } else { //商品无库存或用户积分小于100等情况, 则不执行抢购, 脚本结束 + console.log(`\n抢购终止: 不具备兑换条件`); //打印日志 + } + resolve(); //将主函数的Promise对象状态标记为"成功", 表示已完成抢购任务 + }) +} + +function startExchange(url, item, amount) { + return new Promise((resolve) => { //主函数返回Promise实例对象, 以便后续调用时可以实现顺序执行异步函数 + $.post(url, (error, resp, data) => { //使用post请求查询, 再使用回调函数处理返回的结果 + try { //使用try方法捕获可能出现的代码异常 + if (error) { + throw new Error(error); //如果请求失败, 例如无法联网, 则抛出一个异常 + } else { + const body = JSON.parse(data); //解析响应体json并转化为对象 + if (body.code == 0) { //如果抢购成功, 则输出日志和通知 + console.log(`\n抢购成功: 第${item+1}次\n抢购数量: ${amount}\n消耗积分: ${amount * user.list.real_cost}`); + $.notify('哔哩哔哩漫画抢券', '', `"${productName}"抢购成功, 数量: ${amount}, 消耗积分: ${amount * user.list.real_cost}`); + resolve(true); //将Promise对象的状态标记为"成功", 然后返回一个布尔值true用于跳出循环 + } else { + throw new Error(body.msg || '未知'); //抢购失败则抛出异常 + } + } + } catch (e) { //接住try代码块中抛出的异常并打印日志 + console.log(`\n抢购失败: 第${item+1}次\n失败原因: ${e.message}`); + resolve(); //将Promise对象的状态标记为"成功", 但不返回任何值, 表示继续循环抢购 + } + }) + }) +} + +function nobyda() { + const isSurge = typeof $httpClient != "undefined"; + const isQuanX = typeof $task != "undefined"; + const isNode = typeof require == "function"; + const node = (() => { + if (isNode) { + const request = require('request'); + return { + request + } + } else { + return null; + } + })() + const adapterStatus = (response) => { + if (response) { + if (response.status) { + response["statusCode"] = response.status + } else if (response.statusCode) { + response["status"] = response.statusCode + } + } + return response + } + this.read = (key) => { + if (isQuanX) return $prefs.valueForKey(key) + if (isSurge) return $persistentStore.read(key) + } + this.notify = (title, subtitle, message) => { + if (isQuanX) $notify(title, subtitle, message) + if (isSurge) $notification.post(title, subtitle, message) + if (isNode) console.log(`${title}\n${subtitle}\n${message}`) + } + this.post = (options, callback) => { + options.headers['User-Agent'] = 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/609.3.5.0.2 (KHTML, like Gecko) Mobile/17G80 BiliApp/822 mobi_app/ios_comic channel/AppStore BiliComic/822' + if (isQuanX) { + if (typeof options == "string") options = { + url: options + } + options["method"] = "POST" + $task.fetch(options).then(response => { + callback(null, adapterStatus(response), response.body) + }, reason => callback(reason.error, null, null)) + } + if (isSurge) { + options.headers['X-Surge-Skip-Scripting'] = false + $httpClient.post(options, (error, response, body) => { + callback(error, adapterStatus(response), body) + }) + } + if (isNode) { + node.request.post(options, (error, response, body) => { + callback(error, adapterStatus(response), body) + }) + } + } + this.done = () => { + if (isQuanX || isSurge) { + $done() + } + } +}; \ No newline at end of file diff --git a/Scripts/SignIn/Bilibili/Manga.js b/Scripts/SignIn/Bilibili/Manga.js new file mode 100644 index 0000000..b4ffaed --- /dev/null +++ b/Scripts/SignIn/Bilibili/Manga.js @@ -0,0 +1,107 @@ +/* +哔哩哔哩漫画签到 + +脚本兼容: QuantumultX, Surge, Loon +电报频道:@NobyDa +问题反馈:@NobyDa_bot +如果转载,请注明出处 + +说明: +打开哔哩哔哩漫画后 (AppStore中国区),单击"我的", 如果通知获取cookie成功, 则可以使用此脚本. + +脚本将在每天上午9点执行。 您可以修改执行时间。 + +~~~~~~~~~~~~~~~~ +QX 1.0.10+ : + +[task_local] +0 9 * * * https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js, tag=Bili漫画签到 + +[rewrite_local] +#获取Bili漫画Cookie +^https:\/\/app\.bilibili\.com\/x\/v2\/account\/myinfo url script-request-header https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js + +[mitm] +hostname = app.bilibili.com +~~~~~~~~~~~~~~~~ +*/ + +const $ = new Env(`哔哩哔哩漫画`); + +const cookie = $.getdata("CookieBM") || ''; // 哔哩哔哩漫画Cookie + +const barkKey = ''; //Bark APP 通知推送Key + +if (typeof $request !== 'undefined') { + GetCookie() +} else { + checkin() +} + +function checkin() { + const bilibili = { + url: 'https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn', + headers: { + Cookie: cookie, + }, + body: "platform=ios" + }; + $.post(bilibili, async function(error, response, data) { + if (error && !data) { + $.msgBody = `请求失败!\n${error}`; + } else if (parseInt(response.status) == 200) { + $.msgBody = "签到成功!🎉"; + } else if (/duplicate/.test(data)) { + $.msgBody = "今日已签过 ⚠️"; + } else if (/uid must/.test(data)) { + $.msgBody = "Cookie失效 ‼️‼️"; + } else { + $.msgBody = `签到失败 ‼️\n${data}`; + } + if (barkKey) { + await BarkNotify($, barkKey, $.name, $.msgBody); + } + $.msg($.name, ``, $.msgBody); + $.done(); + }) +} + +function GetCookie() { + var CookieName = "B站漫画"; + var CookieKey = "CookieBM"; + var regex = /SESSDATA=.+?;/; + if ($request.headers) { + var header = Object.keys($request.headers).reduce((t, i) => (t[i.toLowerCase()] = $request.headers[i], t), {})['cookie'] || ''; + if (header.indexOf("SESSDATA=") != -1) { + var CookieValue = regex.exec(header)[0]; + if ($.getdata(CookieKey)) { + if ($.getdata(CookieKey) != CookieValue) { + var cookie = $.setdata(CookieValue, CookieKey); + if (!cookie) { + $.msg("更新" + CookieName + "Cookie失败‼️", "", ""); + } else { + $.msg("更新" + CookieName + "Cookie成功 🎉", "", ""); + } + } + } else { + var cookie = $.setdata(CookieValue, CookieKey); + if (!cookie) { + $.msg("首次写入" + CookieName + "Cookie失败‼️", "", ""); + } else { + $.msg("首次写入" + CookieName + "Cookie成功 🎉", "", ""); + } + } + } else { + $.msg("写入" + CookieName + "Cookie失败‼️", "", "Cookie关键值缺失"); + } + } else { + $.msg("写入" + CookieName + "Cookie失败‼️", "", "配置错误, 无法读取请求头,"); + } + $.done() +} + +//Bark APP notify +async 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}`)}}}; + +// https://github.com/chavyleung/scripts/blob/master/Env.min.js +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){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(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){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,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file