bilibiliHelper.js 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350
  1. /*
  2. 哔哩哔哩每日任务(V1.1)
  3. 更新时间: 2024-04-06
  4. 脚本兼容: QuantumultX, Surge, Loon
  5. 脚本作者: MartinsKing(@ClydeTime)
  6. 软件功能: 登录/观看/分享/投币/直播签到/银瓜子转硬币/大会员积分签到/年度大会员每月B币券+等任务
  7. 注意事项:
  8. 抓取cookie时注意保证账号登录状态;
  9. 账号内须有一定数量的关注数,否则无法完成投币;
  10. 当硬币不足5枚,提示硬币不足,停止投币;
  11. 为保证投币任务成功, 脚本有重试机制(最多重试10次), 以确保任务完成, 前提需要您尽可能多的关注Up主;
  12. 年度大会员每月B币券会在每月1号、15号尝试领取,确保应用正常运行, 以防漏领;
  13. 年度大会员自动充电会在每次领劵之后进行, 默认为自己充电, B币多的用户可自行到boxjs设置,以防误充.
  14. 使用声明: ⚠️此脚本仅供学习与交流,请勿贩卖!⚠️
  15. 脚本参考: Nobyda、Wyatt1026、ABreadTree、chavyleung、SocialSisterYi
  16. ************************
  17. QX, Surge, Loon说明:
  18. ************************
  19. 1.获取cookie
  20. ①后台退出手机B站客户端的情况下, 重新打开APP进入主页
  21. ②通过网址「https://www.bilibili.com」登录,登录后当前网页登录状态失效
  22. 如通知成功获取cookie, 则可以使用此签到脚本.
  23. 脚本将在每天上午7点30执行.
  24. 2.投币设置
  25. 定时任务脚本投币规则为: 随机获取关注列表Up主视频, 默认5视频5硬币, 不点赞.
  26. 用户如需要不投币的版本, 请使用boxjs订阅「https://raw.githubusercontent.com/ClydeTime/BiliBili/main/boxjs/BiliBili.boxjs.json」
  27. 将投币次数置为0, 并保存即可.
  28. /***********************
  29. Surge 脚本配置:
  30. ************************
  31. # B站每日等级任务 「请在模块中添加」
  32. https://raw.githubusercontent.com/ClydeTime/BiliBili/main/modules/BiliBiliDailyBonus.sgmodule
  33. ************************
  34. Loon 远程脚本配置:
  35. ************************
  36. # B站每日等级任务 「请在插件中添加」
  37. https://raw.githubusercontent.com/ClydeTime/BiliBili/main/modules/BiliBiliDailyBonus.plugin
  38. ************************
  39. QuantumultX 远程脚本配置:
  40. ************************
  41. [rewrite local]
  42. # > 哔哩哔哩cookie
  43. ^https?:\/\/app\.bilibili\.com\/x\/resource\/fingerprint\? url script-request-header https://git.jojo21.top/shawenguan/Quantumult-X/raw/master/Scripts/bilibili/bilibiliHelper.js
  44. ^https?:\/\/m.bilibili.com/$ url script-request-header https://git.jojo21.top/shawenguan/Quantumult-X/raw/master/Scripts/bilibili/bilibiliHelper.js
  45. [MITM]
  46. hostname = m.bilibili.com,app.bilibili.com
  47. */
  48. const magicJS = MagicJS(`哔哩哔哩`, "INFO");
  49. const format = (ts, fmt = 'yyyy-MM-dd HH:mm:ss') => {
  50. return magicJS.formatDate(new Date(ts), fmt);
  51. }
  52. const check = key =>
  53. !config.hasOwnProperty(key) ||
  54. !config[key].hasOwnProperty("time") ||
  55. !(config[key]["num"] > 0) ||
  56. format(new Date().toDateString()) > config[key].time
  57. const string2object = cookie => {
  58. let obj = {}
  59. let arr = cookie.split("; ")
  60. arr.forEach(function (val) {
  61. let array = val.split("=")
  62. obj[array[0]] = array[1]
  63. })
  64. return obj
  65. }
  66. const isFlag = exec_times =>
  67. config.user.num === 0 ||
  68. config.watch.num === 0 ||
  69. config.share.num === 0 ||
  70. (config.coins.num < exec_times * 10 && Math.floor(config.user.money) > 5)
  71. const getTimestamp = (d=new Date())=>{
  72. return Math.floor(d.getTime()/1000);
  73. }
  74. const startTime = format();
  75. let cards = [];
  76. let config = {
  77. cookie: {},
  78. cookieStr: "",
  79. key: "",
  80. user: {},
  81. watch: {},
  82. share: {},
  83. coins: {},
  84. score: {}
  85. };
  86. let real_times; //实际需要投币次数
  87. async function Main() {
  88. if (magicJS.isRequest) {
  89. magicJS.logger.info("- 正在获取cookie, 请稍后");
  90. await checkHandleRequest();
  91. } else {
  92. await signBiliBili();
  93. }
  94. magicJS.notification.msg('');
  95. magicJS.done();
  96. }
  97. async function checkHandleRequest(){
  98. const request = magicJS.request;
  99. let cookieStr = request.headers.cookie || request.headers.Cookie;
  100. if(cookieStr){
  101. config.cookie = magicJS.parseCookies(cookieStr);
  102. const PStoreConfig = magicJS.data.read("bilibili_daily_bonus", {})
  103. if (PStoreConfig.cookie && PStoreConfig.cookie.bili_jct !== config.cookie.bili_jct) {
  104. if (PStoreConfig.Settings) config.Settings = PStoreConfig.Settings // 同步boxjs数据
  105. config.FirstInsert = false;
  106. magicJS.logger.info(magicJS.toStr(config));
  107. await persistentStore(config)
  108. } else if (PStoreConfig.cookie) {
  109. magicJS.logger.info("- cookie未失效,无需更新");
  110. } else {
  111. config.FirstInsert = true;
  112. await persistentStore(config);
  113. }
  114. }
  115. }
  116. async function persistentStore(config){
  117. if (config.cookie.DedeUserID) {
  118. const url = $request.url;
  119. config.key = url.match(/.*access_key=(.*?)&build/)?.[1];
  120. config.cookieStr = `DedeUserID=${config.cookie.DedeUserID}; DedeUserID__ckMd5=${config.cookie.DedeUserID__ckMd5}; SESSDATA=${config.cookie.SESSDATA}; bili_jct=${config.cookie.bili_jct}; sid=${config.cookie.sid}`;
  121. if (!config.key) { //网页方式登录
  122. let auth_code = "0", access_key = "0", login_confirm = false;
  123. auth_code = await getAuthCode();
  124. if (auth_code !== "0"){
  125. login_confirm = await loginConfirm(auth_code)
  126. }
  127. if (login_confirm){
  128. access_key = await getAccessKey(auth_code)
  129. }
  130. if (access_key !== "0") {
  131. config.key = access_key
  132. } else {
  133. magicJS.logger.info("- 获取用户access_key失败!");
  134. magicJS.notification.post(magicJS.scriptName, "🤒获取用户access_key失败!");
  135. }
  136. }
  137. const isFirstInsert = config.FirstInsert;
  138. delete config.FirstInsert;
  139. magicJS.logger.info(magicJS.toStr(config))
  140. const successMessage = magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config))
  141. ? "🎉cookie存储成功"
  142. : "🤒cookie存储失败"
  143. magicJS.notification.post(magicJS.scriptName, isFirstInsert ? "首次获取cookie" : "检测到cookie已更新", successMessage);
  144. } else {
  145. magicJS.notification.post(magicJS.scriptName, "- 尚未登录, 请登录后重新获取cookie");
  146. }
  147. }
  148. async function signBiliBili() {
  149. config = magicJS.data.read("bilibili_daily_bonus", {});
  150. if (config.cookie && await me()) {
  151. await queryStatus();
  152. let exec_times = config.Settings?.exec; //用户设置投币次数
  153. if (!Boolean(exec_times)) {
  154. exec_times = 5;
  155. real_times = 5 - (Number(config.coins.num) / 10);
  156. } else {
  157. exec_times = Number(exec_times);
  158. real_times = Math.max(0, exec_times - (Number(config.coins.num) / 10));
  159. }
  160. let flag = isFlag(exec_times);
  161. if (flag){
  162. await dynamic();
  163. if (cards.length) {
  164. let item = cards[Math.floor(Math.random() * cards.length)];
  165. let card = magicJS.toObj(item.card);
  166. short_link = encodeURIComponent(card?.short_link_v2.replace(/\\\//g, '/'));
  167. await watch(item.desc.rid, item.desc.bvid, card.cid);
  168. await share(item.desc.rid, card.cid, short_link);
  169. } else {
  170. magicJS.logger.info("- 获取视频失败,请重试或寻求帮助");
  171. }
  172. magicJS.logger.info("3️⃣ 投币任务");
  173. if (typeof config.coins.failures !== 'undefined' && config.coins.failures > 0){
  174. config.coins.failures = 0; //重置投币失败次数
  175. }
  176. if (real_times === 0){
  177. magicJS.logger.info(`- 今日已完成 ${config.coins.time}`);
  178. } else {
  179. for (let i = 0; i < real_times; i ++) {
  180. if (Math.floor(config.user.money) <= 5) {
  181. magicJS.logger.info("- 硬币不足,投币失败");
  182. break;
  183. } else {
  184. await coin();
  185. await magicJS.utils.sleep(300) //减少频繁请求概率
  186. }
  187. }
  188. }
  189. magicJS.logger.info("---- 将尝试额外任务")
  190. } else {
  191. magicJS.logger.info("---- 经验值任务均已完成,将尝试额外任务")
  192. }
  193. await liveSign()
  194. await silver2coin()
  195. await vipScoreSign()
  196. if (config.user.vipStatus === 1) {
  197. await vipExtraEx()
  198. await vipScoreGo()
  199. await vipScoreFan()
  200. await vipScoreMovie()
  201. await vipScoreDress()
  202. await vipWatchAccept()
  203. //B币券每月尝试两次领取
  204. let day = magicJS.utils.formatTime(new Date(), 'dd');
  205. if (day === '1' || day === '15') {
  206. if (config.user.vipType === 2) {
  207. await vipPrivilege(1)
  208. await magicJS.utils.sleep(800) //延迟执行,防止领劵延迟
  209. let charge_mid = config.Settings?.charge_mid || config.user.mid //用户设置充电id
  210. let bp_num = config.Settings?.bp_num || 5 //用户设置充电数量
  211. await Charge(charge_mid, bp_num)//充电
  212. for (let i = 2; i <= 7; i++) await vipPrivilege(i)
  213. } else if (config.user.vipType === 1) {
  214. await vipPrivilege(6)
  215. await vipPrivilege(7)
  216. }
  217. }
  218. }
  219. flag = !isFlag(exec_times)
  220. let title = `登录${config.user.num}/观看${config.watch.num}/分享${config.share.num}/投币${config.coins.num / 10}${flag ? "已完成" : "未完成"}`
  221. magicJS.logger.info(`#### ${title}`)
  222. magicJS.logger.info(`- 登录时间: ${config.user.time || "暂无"}`)
  223. magicJS.logger.info(`- 观看时间: ${config.watch.time || "暂无"}`)
  224. magicJS.logger.info(`- 分享时间: ${config.share.time || "暂无"}`)
  225. magicJS.logger.info(`- 投币时间: ${config.coins.time || "暂无"}`)
  226. notice = {
  227. title: `[${config.user.uname}]`,
  228. subTitle: `${flag ? "✅任务完成" : "❗️有未完成的任务"}`,
  229. content:
  230. `任务:登录(观看)${check("watch") ? "" : "+10exp"} 分享${check("share") ? "" : "+5exp"} 投币${check("coins") ? "" : "+50exp"}\n` +
  231. `经验:当前${config.user.level_info.current_exp}/下级${config.user.level_info.next_exp}/满级28800\n` +
  232. `等级:当前${config.user.level_info.current_level}级 升满级最快需${Math.ceil((config.user.v6_exp)/65)}天`,
  233. }
  234. magicJS.notification.post(notice.title, notice.subTitle, notice.content)
  235. } else {
  236. magicJS.notification.post(`任务失败`,`📅 ${startTime}`, "🤒请更新cookie")
  237. }
  238. }
  239. async function getAuthCode() {
  240. return new Promise((resolve, reject) => {
  241. const body = {
  242. appkey: "27eb53fc9058f8c3",
  243. local_id: 0,
  244. ts: getTimestamp()
  245. };
  246. const sortedBody = magicJS.objToQueryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort())));
  247. const sign = md5(sortedBody + 'c2ed53a74eeefe3cf99fbd01d8c9c375');
  248. body['sign'] = sign;
  249. const myRequest = {
  250. url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/auth_code",
  251. headers: {
  252. "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
  253. },
  254. body: magicJS.objToQueryStr(body),
  255. }
  256. magicJS.http.post(myRequest).then(response => {
  257. try {
  258. const body = response.body;
  259. if (body.code === 0 && body.message === "0") {
  260. magicJS.logger.info("- 获取auth_code成功");
  261. resolve(body.data.auth_code);
  262. } else {
  263. magicJS.logger.info("- 获取auth_code失败");
  264. resolve("0");
  265. }
  266. } catch (e) {
  267. magicJS.logger.error(e);
  268. resolve();
  269. }
  270. }).catch(err => {
  271. const msg = `获取AuthCode异常\n${JSON.stringify(err)}`;
  272. magicJS.logger.error(msg);
  273. reject(msg);
  274. });
  275. });
  276. }
  277. async function loginConfirm(auth_code) {
  278. return new Promise((resolve, reject) => {
  279. const body = {
  280. auth_code,
  281. build: 7082000,
  282. csrf: config.cookie.bili_jct
  283. };
  284. const myRequest = {
  285. url: "https://passport.bilibili.com/x/passport-tv-login/h5/qrcode/confirm",
  286. headers: {
  287. "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
  288. 'cookie': `DedeUserID=${config.cookie.DedeUserID}; SESSDATA=${config.cookie.SESSDATA}`
  289. },
  290. body: magicJS.objToQueryStr(body),
  291. };
  292. magicJS.http.post(myRequest).then(response => {
  293. try {
  294. const body = response.body;
  295. if (body.code === 0 && body.message === "0") {
  296. magicJS.logger.info("- 确认登录成功")
  297. resolve(true);
  298. } else {
  299. magicJS.logger.info("- 确认登录失败")
  300. resolve(false);
  301. }
  302. } catch (e) {
  303. magicJS.logger.error(e);
  304. resolve();
  305. }
  306. }).catch(err => {
  307. const msg = `确认登录异常\n${JSON.stringify(err)}`;
  308. magicJS.logger.error(msg);
  309. reject(msg);
  310. });
  311. });
  312. }
  313. async function getAccessKey(auth_code) {
  314. return new Promise((resolve, reject) => {
  315. const body = {
  316. appkey: "27eb53fc9058f8c3",
  317. auth_code,
  318. local_id: 0,
  319. ts: getTimestamp()
  320. }
  321. const sortedBody = magicJS.objToQueryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort())));
  322. const sign = md5(sortedBody + 'c2ed53a74eeefe3cf99fbd01d8c9c375');
  323. body['sign'] = sign;
  324. const myRequest = {
  325. url: "https://passport.bilibili.com/x/passport-tv-login/qrcode/poll",
  326. headers: {
  327. "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
  328. },
  329. body: magicJS.objToQueryStr(body),
  330. };
  331. magicJS.http.post(myRequest).then(response => {
  332. try {
  333. const body = response.body;
  334. if (body.code === 0 && body.message === "0") {
  335. magicJS.logger.info("- 获取access_key成功");
  336. resolve(body.data.access_token);
  337. } else {
  338. magicJS.logger.info("- 获取access_key失败");
  339. resolve("0");
  340. }
  341. } catch (e) {
  342. magicJS.logger.error(e);
  343. resolve();
  344. }
  345. }).catch(err => {
  346. const msg = `获取AccessKey异常\n${JSON.stringify(err)}`;
  347. magicJS.logger.error(msg);
  348. reject(msg);
  349. });
  350. });
  351. }
  352. async function watch(aid, bvid, cid) {
  353. return new Promise((resolve, reject) => {
  354. magicJS.logger.info("1️⃣ 观看(登录)任务");
  355. if (check("watch")) {
  356. magicJS.logger.info(`- 正在观看(登录)(${bvid})`);
  357. const body = {
  358. aid,
  359. cid,
  360. bvid,
  361. mid: config.user.mid,
  362. csrf: config.cookie.bili_jct,
  363. played_time : 1,
  364. real_played_time: 1,
  365. realtime: 1,
  366. start_ts: getTimestamp(),
  367. type: 3,
  368. dt: 2,
  369. play_type: 0,
  370. from_spmid: 0,
  371. spmid: 0,
  372. auto_continued_play: 0,
  373. refer_url: "https%3A%2F%2Ft.bilibili.com%2F",
  374. bsource: ""
  375. };
  376. const myRequest = {
  377. url: 'https://api.bilibili.com/x/click-interface/web/heartbeat',
  378. headers: {
  379. "cookie": config.cookieStr,
  380. "referrer": `https://www.bilibili.com/video/${bvid}`
  381. },
  382. body: magicJS.objToQueryStr(body),
  383. };
  384. magicJS.http.post(myRequest).then(response => {
  385. const body = response.body;
  386. if (body?.code === 0) {
  387. magicJS.logger.info(`- 累计观看(登录)次数 ${(config.watch.num || 0) + 1}`);
  388. config.user.num = (config.user.num || 0) + 1;
  389. config.watch.num = (config.watch.num || 0) + 1;
  390. magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
  391. } else {
  392. magicJS.logger.info("- 观看失败, 失败原因: " + body?.message);
  393. }
  394. resolve(body);
  395. }).catch(err => {
  396. const msg = `观看异常\n${JSON.stringify(err)}`;
  397. magicJS.logger.error(msg);
  398. reject();
  399. });
  400. } else {
  401. magicJS.logger.info(`- 今日已经观看 ${config.watch.time}`);
  402. resolve();
  403. }
  404. });
  405. }
  406. async function share(aid, cid, short_link) {
  407. return new Promise((resolve, reject) => {
  408. magicJS.logger.info("2️⃣ 分享任务");
  409. if (check("share")) {
  410. magicJS.logger.info("- 正在分享, aid=" + aid);
  411. const body = {
  412. access_key: config.key.replace(/&actionKey=.*?&appkey=.*$/, ''),
  413. actionKey: 'appkey',
  414. appkey: '27eb53fc9058f8c3',
  415. build: '72700100',
  416. c_locale: 'zh-Hans_CN',
  417. device: 'phone',
  418. disable_rcmd: 0,
  419. link: short_link,
  420. mobi_app: 'iphone',
  421. object_extra_fields: '%7B%7D',
  422. oid: aid,
  423. panel_type: 1,
  424. platform: 'ios',
  425. s_locale:'zh-Hans_CN',
  426. share_channel: 'WEIXIN',
  427. share_id: 'main.ugc-video-detail.0.0.pv',
  428. share_origin: 'vinfo_share',
  429. sid: cid,
  430. spm_id: 'main.ugc-video-detail.0.0',
  431. statistics: '%7B%22appId%22%3A1%2C%22version%22%3A%227.27.0%22%2C%22abtest%22%3A%22%22%2C%22platform%22%3A1%7D',
  432. success: 1,
  433. ts: getTimestamp()
  434. }
  435. const sign = md5(magicJS.objToQueryStr(body) + 'c2ed53a74eeefe3cf99fbd01d8c9c375');
  436. body['sign'] = sign;
  437. const myRequest = {
  438. url: 'https://api.bilibili.com/x/share/finish',
  439. headers: {},
  440. body: magicJS.objToQueryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort())))
  441. };
  442. magicJS.http.post(myRequest).then(response => {
  443. const body = response.body;
  444. if (body?.code === 0) {
  445. config.share.num = (config.share.num || 0) + 1;
  446. magicJS.logger.info("- 分享成功");
  447. magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
  448. } else {
  449. magicJS.logger.info("- 分享失败, 失败原因: " + body?.message);
  450. }
  451. resolve(body);
  452. }).catch(err => {
  453. const msg = `分享异常\n${JSON.stringify(err)}`;
  454. magicJS.logger.error(msg);
  455. reject();
  456. });
  457. } else {
  458. magicJS.logger.info(`- 今日已经分享 ${config.share.time}`);
  459. resolve();
  460. }
  461. });
  462. }
  463. async function coin() {
  464. return new Promise((resolve, reject) => {
  465. if (config.coins.num >= 50) {
  466. magicJS.logger.info(`- 今日已完成 ${config.coins.time}`);
  467. resolve();
  468. return;
  469. }
  470. let like_uid_list = await getFavUid()
  471. if (like_uid_list && like_uid_list.length > 0) {
  472. let aid = await getFavAid(like_uid_list)
  473. //magicJS.logger.info("即将投币的视频aid: " + aid)
  474. if (aid !== 0) {
  475. const body = {
  476. aid,
  477. multiply: 1,
  478. select_like: 0,
  479. cross_domain: true,
  480. csrf: config.cookie.bili_jct
  481. }
  482. const myRequest = {
  483. url: "https://api.bilibili.com/x/web-interface/coin/add",
  484. headers: {
  485. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
  486. 'accept': 'application/json, text/plain, */*',
  487. 'content-type': 'application/x-www-form-urlencoded',
  488. 'origin': 'https://www.bilibili.com',
  489. 'referer': 'https://www.bilibili.com/video/BV1MT411G7fG?vd_source=1970993e2eff4af7be029aefcfa468b8',
  490. 'cookie': config.cookieStr + ';buvid3=fuckchenruilovelaoliu'
  491. },
  492. body: magicJS.objToQueryStr(body)
  493. }
  494. magicJS.http.post(myRequest).then(async response => {
  495. try {
  496. const body = response.body;
  497. if (body?.code === 0 && body?.message === "0") {
  498. magicJS.logger.info("- 投币成功");
  499. config.user.money -= 1;
  500. config.coins.num += 10;
  501. magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
  502. } else {
  503. magicJS.logger.info("- 投币失败,失败原因 " + body.message);
  504. config.coins.failures = (config.coins.failures === 0 || typeof config.coins.failures === 'undefined' ? 1 : config.coins.failures + 1);
  505. magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
  506. if (config.coins.failures < 11) {
  507. magicJS.logger.info("- 正在重试...重试次数 " + (config.coins.failures - 1) + "(超过十次不再重试)");
  508. await coin();
  509. }
  510. }
  511. } catch (e) {
  512. magicJS.logger.error(e);
  513. }
  514. resolve();
  515. }).catch(err => {
  516. const msg = `投币异常\n${JSON.stringify(err)}`;
  517. magicJS.logger.error(msg);
  518. reject();
  519. });
  520. } else {
  521. magicJS.logger.info("获取随机投币视频失败");
  522. resolve();
  523. }
  524. } else {
  525. magicJS.logger.info("获取随机关注用户列表失败");
  526. resolve();
  527. }
  528. });
  529. }
  530. async function getFavUid() {
  531. return new Promise((resolve, reject) => {
  532. const myRequest = {
  533. url: `https://api.bilibili.com/x/relation/followings?vmid=${config.cookie.DedeUserID}&ps=10&order_type=attention`,
  534. headers: {
  535. 'cookie': config.cookieStr
  536. }
  537. };
  538. magicJS.http.get(myRequest).then(response => {
  539. try {
  540. const body = response.body;
  541. let like_uid_list = new Array();
  542. if (body?.code === 0) {
  543. magicJS.logger.info("- 获取关注列表成功");
  544. let like_list = body?.data?.list;
  545. for (let i = 0; i < like_list.length; i ++) {
  546. like_uid_list[i] = like_list[i].mid;
  547. }
  548. resolve(like_uid_list);
  549. } else {
  550. magicJS.logger.info("- 获取关注列表成失败");
  551. magicJS.logger.info("- 失败原因 " + body?.message);
  552. resolve(like_uid_list);
  553. }
  554. } catch (e) {
  555. magicJS.logger.error(JSON.stringify(e));
  556. resolve();
  557. }
  558. }).catch(err => {
  559. const msg = `获取关注列表异常\n${JSON.stringify(err)}`;
  560. magicJS.logger.error(msg);
  561. reject();
  562. });
  563. });
  564. }
  565. async function getFavAid(arr) {
  566. return new Promise((resolve, reject) => {
  567. //magicJS.logger.info("- 获取关注列表中的随机视频")
  568. let random_int = Math.floor((Math.random()*arr.length));
  569. let random_mid = arr[random_int];
  570. let wbiSigns = getWbiSigns({mid: random_mid});
  571. const myRequest = {
  572. url: `https://api.bilibili.com/x/space/wbi/arc/search?${wbiSigns}`,
  573. headers: {
  574. 'cookie': config.cookieStr
  575. }
  576. };
  577. magicJS.http.get(myRequest).then(response => {
  578. try {
  579. const body = response.body;
  580. if (body?.code === 0) {
  581. magicJS.logger.info("- 获取投币视频成功");
  582. let vlist = body.data?.list?.vlist;
  583. let random_v_int = Math.floor((Math.random() * vlist.length));
  584. let aid = vlist[random_v_int]?.aid;
  585. magicJS.logger.info("- 作者: " + vlist[random_v_int]['author'] + "; 视频标题: " + vlist[random_v_int]['title']);
  586. resolve(aid);
  587. } else {
  588. magicJS.logger.info("- 获取投币视频失败");
  589. magicJS.logger.info("- 失败原因 " + body?.message);
  590. resolve(0);
  591. }
  592. } catch (e) {
  593. magicJS.logger.error(e);
  594. resolve();
  595. }
  596. }, reason => {
  597. magicJS.logger.info("- 获取投币视频失败");
  598. magicJS.logger.info("- 失败原因 " + magicJS.toStr(reason));
  599. resolve(0);
  600. }).catch(err => {
  601. const msg = `获取投币视频异常\n${JSON.stringify(err)}`;
  602. magicJS.logger.error(msg);
  603. reject();
  604. });
  605. });
  606. }
  607. async function silver2coin() {
  608. return new Promise((resolve, reject) => {
  609. magicJS.logger.info("#### 银瓜子兑换硬币任务");
  610. const body = {
  611. csrf: config.cookie.bili_jct,
  612. csrf_token: config.cookie.bili_jct
  613. };
  614. const myRequest = {
  615. url: "https://api.live.bilibili.com/xlive/revenue/v1/wallet/silver2coin",
  616. headers: {
  617. 'cookie': config.cookieStr
  618. },
  619. body: magicJS.objToQueryStr(body)
  620. };
  621. magicJS.http.get(myRequest).then(response => {
  622. try {
  623. let result = response.body;
  624. let title = `银瓜子转硬币`;
  625. // 兑换成功
  626. if (result && result.code === 0) {
  627. let subTitle = `- ${result.message}`;
  628. let detail = `- 成功兑换: ${result.data.coin} 个硬币\n当前银瓜子: ${result.data.silver} , 当前金瓜子: ${result.data.gold}`;
  629. magicJS.logger.info(subTitle);
  630. magicJS.logger.info(detail);
  631. magicJS.notification.post(title, subTitle, detail);
  632. }
  633. // 兑换中止(重复兑换&银瓜子不足)
  634. else if (result && result.code === 403) {
  635. let subTitle = "- 未成功兑换";
  636. let detail = `- 原因: ${result.message}`;
  637. magicJS.logger.info(subTitle);
  638. magicJS.logger.info(detail);
  639. magicJS.notification.post(title, subTitle, detail);
  640. }
  641. // 兑换失败
  642. else {
  643. let subTitle = "- 兑换失败";
  644. let detail = `- 原因: ${result.message}`;
  645. magicJS.logger.info(subTitle);
  646. magicJS.logger.info(detail);
  647. magicJS.notification.post(title, subTitle, detail);
  648. }
  649. } catch (e) {
  650. magicJS.logger.error(e);
  651. }
  652. resolve();
  653. }).catch(err => {
  654. const msg = `兑换异常\n${JSON.stringify(err)}`;
  655. magicJS.logger.error(msg);
  656. reject(msg);
  657. });
  658. });
  659. }
  660. async function liveSign() {
  661. return new Promise((resolve, reject) => {
  662. magicJS.logger.info("#### 直播签到任务");
  663. const myRequest = {
  664. url: "https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign",
  665. headers: {
  666. 'cookie': config.cookieStr
  667. }
  668. };
  669. magicJS.http.get(myRequest).then(response => {
  670. try {
  671. let body = response.body;
  672. if (body?.code === 0) {
  673. magicJS.logger.info("- 签到成功");
  674. magicJS.logger.info(`签到奖励:${body.data.text},连续签到${body.data.hadSignDays}天`);
  675. } else if (body && body.code === 1011040){
  676. magicJS.logger.info("- 今日已完成");
  677. } else {
  678. magicJS.logger.info("- 签到失败");
  679. magicJS.logger.info("- 失败原因 " + body?.message);
  680. }
  681. } catch (e) {
  682. magicJS.logger.error(e);
  683. }
  684. resolve();
  685. }).catch(err => {
  686. const msg = `签到异常\n${JSON.stringify(err)}`;
  687. magicJS.logger.error(msg);
  688. reject(msg);
  689. });
  690. });
  691. }
  692. async function vipScoreSign() {
  693. return new Promise((resolve, reject) => {
  694. magicJS.logger.info("#### 大会员大积分签到任务");
  695. if (config.user.vipStatus === 0) {
  696. magicJS.logger.info("- 当前用户非大会员, 无法完成任务");
  697. resolve();
  698. } else {
  699. if (check("score")) {
  700. const myRequest = {
  701. url: "https://api.bilibili.com/pgc/activity/score/task/sign",
  702. method: "POST",
  703. headers: {
  704. 'Referer': 'https://big.bilibili.com/mobile/bigPoint/task',
  705. 'cookie': config.cookieStr
  706. }
  707. };
  708. magicJS.http.get(myRequest).then(response => {
  709. try {
  710. const body = response.body;
  711. if (body?.code === 0 && body?.message === "success") {
  712. magicJS.logger.info("- 签到成功")
  713. config.score.time = startTime
  714. config.score.num = 1
  715. magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config))
  716. } else {
  717. magicJS.logger.info("- 签到失败")
  718. magicJS.logger.info("- 失败原因 " + body?.message)
  719. }
  720. } catch (e) {
  721. magicJS.logger.error(e);
  722. }
  723. resolve();
  724. }).catch(err => {
  725. const msg = `签到异常\n${JSON.stringify(err)}`;
  726. magicJS.logger.error(msg);
  727. reject();
  728. });
  729. } else {
  730. magicJS.logger.info("- 今日已完成");
  731. resolve();
  732. }
  733. }
  734. });
  735. }
  736. async function vipExtraEx() {
  737. return new Promise((resolve, reject) => {
  738. magicJS.logger.info("#### 大会员每日额外经验值");
  739. const body = {
  740. csrf: config.cookie.bili_jct,
  741. ts: getTimestamp(),
  742. buvid: config.cookie.Buvid,
  743. mobi_app: 'iphone',
  744. platform: 'ios',
  745. appkey: '27eb53fc9058f8c3',
  746. access_key: config.key
  747. };
  748. const sortedBody = magicJS.objToQueryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort())));
  749. const sign = md5(sortedBody + 'c2ed53a74eeefe3cf99fbd01d8c9c375');
  750. body['sign'] = sign;
  751. const myRequest = {
  752. url: "https://api.bilibili.com/x/vip/experience/add",
  753. headers: {
  754. 'accept': 'application/json, text/plain, */*',
  755. 'app-key': 'iphone'
  756. },
  757. body: magicJS.objToQueryStr(body)
  758. };
  759. magicJS.http.get(myRequest).then(response => {
  760. try {
  761. const body = response.body;
  762. if (body?.code === 0 && body?.message === "0") {
  763. magicJS.logger.info("- 成功获得10经验值");
  764. } else {
  765. magicJS.logger.info("- 每日额外经验任务失败");
  766. magicJS.logger.info("- 失败原因 " + body?.message);
  767. }
  768. } catch (e) {
  769. magicJS.logger.error(e);
  770. }
  771. resolve();
  772. }).catch(err => {
  773. const msg = `获取额外经验异常\n${JSON.stringify(err)}`;
  774. magicJS.logger.error(msg);
  775. reject();
  776. });
  777. });
  778. }
  779. async function vipScoreGo() {
  780. return new Promise((resolve, reject) => {
  781. magicJS.logger.info("#### 大会员浏览会员购10s任务");
  782. const myRequest = {
  783. url: "https://show.bilibili.com/api/activity/fire/common/event/dispatch",
  784. headers: {
  785. 'Content-Type' : 'application/json',
  786. 'Cookie': config.cookieStr
  787. },
  788. body: `{"eventId":"hevent_oy4b7h3epeb"}`
  789. };
  790. magicJS.http.get(myRequest).then(response => {
  791. try {
  792. const body = response.body;
  793. if (body?.code === 0 && body?.message === "SUCCESS") {
  794. magicJS.logger.info("- 成功获得10点大积分");
  795. } else {
  796. magicJS.logger.info("- 浏览会员购任务失败");
  797. magicJS.logger.info("- 失败原因 " + body?.message);
  798. }
  799. } catch (e) {
  800. magicJS.logger.error(e);
  801. }
  802. resolve();
  803. }).catch(err => {
  804. const msg = `浏览会员购任务异常\n${JSON.stringify(err)}`;
  805. magicJS.logger.error(msg);
  806. reject();
  807. });
  808. });
  809. }
  810. async function vipScoreFan() {
  811. return new Promise((resolve, reject) => {
  812. magicJS.logger.info("#### 大会员浏览追番频道10s任务");
  813. const myRequest = {
  814. url: `https://api.bilibili.com/pgc/activity/deliver/task/complete?access_key=${config.key}&position=jp_channel&sign=768d600feba34e6d1109e4157c0f0c5f&task_sign=557D1ACE13E9E81393259FFB621D6D0E`,
  815. method: "POST",
  816. headers: {}
  817. };
  818. magicJS.http.get(myRequest).then(response => {
  819. try {
  820. const body = response.body;
  821. if (body?.code === 0 && body?.message === "success") {
  822. magicJS.logger.info("- 成功获得10点大积分");
  823. } else {
  824. magicJS.logger.info("- 浏览追番频道任务失败");
  825. magicJS.logger.info("- 失败原因 " + body?.message);
  826. }
  827. } catch (e) {
  828. magicJS.logger.error(e);
  829. }
  830. resolve();
  831. }).catch(err => {
  832. const msg = `浏览追番频道任务异常\n${JSON.stringify(err)}`;
  833. magicJS.logger.error(msg);
  834. reject();
  835. });
  836. });
  837. }
  838. async function vipScoreMovie() {
  839. return new Promise((resolve, reject) => {
  840. magicJS.logger.info("#### 大会员浏览影视频道10s任务");
  841. const myRequest = {
  842. url: `https://api.bilibili.com/pgc/activity/deliver/task/complete?access_key=${config.key}&position=tv_channel&sign=09ece1c295cb86d74778b93c59c0da3a&task_sign=B7DA5FAE25C39F53C62C03076CF2878B`,
  843. method: "POST",
  844. headers: {}
  845. };
  846. magicJS.http.get(myRequest).then(response => {
  847. try {
  848. const body = response.body;
  849. if (body?.code === 0 && body?.message === "success") {
  850. magicJS.logger.info("- 成功获得10点大积分");
  851. } else {
  852. magicJS.logger.info("- 浏览影视频道任务失败");
  853. magicJS.logger.info("- 失败原因 " + body?.message);
  854. }
  855. } catch (e) {
  856. magicJS.logger.error(e);
  857. }
  858. resolve();
  859. }).catch(err => {
  860. const msg = `浏览影视频道任务异常\n${JSON.stringify(err)}`;
  861. magicJS.logger.error(msg);
  862. reject();
  863. });
  864. });
  865. }
  866. async function vipScoreDress() {
  867. return new Promise((resolve, reject) => {
  868. magicJS.logger.info("#### 大会员浏览装扮商城主页任务");
  869. const body = {
  870. csrf: config.cookie.bili_jct,
  871. ts: getTimestamp(),
  872. taskCode: 'dress-view',
  873. access_key: config.key
  874. };
  875. const myRequest = {
  876. url: 'https://api.bilibili.com/pgc/activity/score/task/complete/v2',
  877. headers: {},
  878. body: magicJS.objToQueryStr(body)
  879. };
  880. magicJS.http.get(myRequest).then(response => {
  881. try {
  882. const body = response.body;
  883. if (body?.code === 0 && body?.message === "success") {
  884. magicJS.logger.info("- 成功获得10点大积分");
  885. } else {
  886. magicJS.logger.info("- 浏览装扮商城主页任务失败");
  887. }
  888. } catch (e) {
  889. magicJS.logger.error(e);
  890. }
  891. resolve();
  892. }).catch(err => {
  893. const msg = `浏览装扮商城主页任务异常\n${JSON.stringify(err)}`;
  894. magicJS.logger.error(msg);
  895. reject();
  896. });
  897. });
  898. }
  899. async function vipWatchAccept() {
  900. return new Promise((resolve, reject) => {
  901. magicJS.logger.info("#### 接取大会员观看剧集10min任务");
  902. const body = {
  903. csrf: config.cookie.bili_jct,
  904. ts: getTimestamp(),
  905. taskCode: 'ogvwatchnew',
  906. mobi_app: 'iphone',
  907. platform: 'ios',
  908. appkey: '27eb53fc9058f8c3',
  909. access_key: config.key
  910. };
  911. const sortedBody = magicJS.objToQueryStr(Object.fromEntries(new Map(Array.from(Object.entries(body)).sort())));
  912. const sign = md5(sortedBody + 'c2ed53a74eeefe3cf99fbd01d8c9c375');
  913. body['sign'] = sign
  914. const myRequest = {
  915. url: 'https://api.bilibili.com/pgc/activity/score/task/receive/v2',
  916. headers: {
  917. 'Content-Type': 'application/x-www-form-urlencoded',
  918. 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/615.2.9.10.4 (KHTML, like Gecko) Mobile/20F75 BiliApp/77200100 os/ios model/iPhone 15 Pro Max mobi_app/iphone build/77200100 osVer/17.4.1 network/2 channel/AppStore c_locale/zh-Hans_CN s_locale/zh-Hans_CN disable_rcmd/0',
  919. 'Cookie': `SESSDATA=${config.cookie.SESSDATA}`,
  920. 'Referer': `https://big.bilibili.com/mobile/bigPoint/task`
  921. },
  922. body: magicJS.objToQueryStr(body)
  923. };
  924. magicJS.http.get(myRequest).then(response => {
  925. try {
  926. const body = response.body;
  927. if (body?.code === 0 && body?.message === "success") {
  928. magicJS.logger.info("- 大会员观看剧集任务接取成功, 需自行观看");
  929. } else {
  930. magicJS.logger.info("- 大会员观看剧集任务接取失败");
  931. magicJS.logger.info("- 失败原因 " + body?.message);
  932. }
  933. } catch (e) {
  934. magicJS.logger.error(e);
  935. }
  936. resolve();
  937. }).catch(err => {
  938. const msg = `大会员观看剧集任务异常\n${JSON.stringify(err)}`;
  939. magicJS.logger.error(msg);
  940. reject();
  941. });
  942. });
  943. }
  944. async function vipPrivilege(type) {
  945. return new Promise((resolve, reject) => {
  946. magicJS.logger.info("#### 领取大会员月度福利");
  947. const body = {
  948. csrf: config.cookie.bili_jct,
  949. type
  950. };
  951. const myRequest = {
  952. url: 'https://api.bilibili.com/x/vip/privilege/receive',
  953. headers: {
  954. 'Cookie': config.cookieStr
  955. },
  956. body: magicJS.objToQueryStr(body)
  957. };
  958. magicJS.http.get(myRequest).then(response => {
  959. try {
  960. const body = response.body;
  961. if (body?.code === 0) {
  962. switch (type) {
  963. case 1:
  964. magicJS.logger.info("- 领取年度大会员每月B币券成功");
  965. magicJS.notification.post("年度大会员月度福利", "B币券", "🎉🎉🎉领取成功");
  966. break
  967. case 2:
  968. magicJS.logger.info("- 领取年度大会员每月会员购优惠券成功");
  969. break
  970. case 3:
  971. magicJS.logger.info("- 领取年度大会员每月漫画福利券成功");
  972. break
  973. case 4:
  974. magicJS.logger.info("- 领取年度大会员每月会员购包邮券成功");
  975. break
  976. case 5:
  977. magicJS.logger.info("- 领取年度大会员每月漫画商城优惠券成功");
  978. break
  979. case 6:
  980. magicJS.logger.info("- 领取大会员每月装扮体验卡成功");
  981. break
  982. case 7:
  983. magicJS.logger.info("- 领取大会员每月课堂优惠券成功");
  984. break
  985. default:
  986. break
  987. }
  988. } else {
  989. magicJS.logger.info("- 领取大会员每月福利失败, 福利编码为" + type);
  990. magicJS.logger.info("- 失败原因 " + body?.message);
  991. if (type === 1) {
  992. magicJS.notification.post("年度大会员月度福利", "B币券领取失败", "失败原因为: " + body?.message);
  993. }
  994. //其他福利没什么用,失败也无需单独通知
  995. }
  996. } catch (e) {
  997. magicJS.logger.error(e);
  998. }
  999. resolve();
  1000. }).catch(err => {
  1001. const msg = `领取大会员月度福利异常\n${JSON.stringify(err)}`;
  1002. magicJS.logger.error(msg);
  1003. reject();
  1004. });
  1005. });
  1006. }
  1007. async function Charge(mid, bp_num) {
  1008. return new Promise((resolve, reject) => {
  1009. magicJS.logger.info("#### B币券自动充电");
  1010. const body = {
  1011. bp_num,
  1012. is_bp_remains_prior: true,
  1013. up_mid: mid,
  1014. otype: 'up',
  1015. oid: mid,
  1016. csrf: config.cookie.bili_jct
  1017. };
  1018. const myRequest = {
  1019. url: 'https://api.bilibili.com/x/ugcpay/web/v2/trade/elec/pay/quick',
  1020. headers: {
  1021. 'Cookie': config.cookieStr
  1022. },
  1023. body: magicJS.objToQueryStr(body)
  1024. };
  1025. magicJS.http.get(myRequest).then(response => {
  1026. try {
  1027. const body = response.body;
  1028. if (body?.code === 0) {
  1029. if (body?.data?.status === 4) {
  1030. if (mid === config.user.mid) {
  1031. magicJS.logger.info("- 为自己充电成功");
  1032. } else {
  1033. magicJS.logger.info(`- 为用户id为${mid}的用户充电成功`);
  1034. }
  1035. } else if (body?.data?.status === -4) {
  1036. magicJS.logger.info("- 充电失败, B币不足");
  1037. } else {
  1038. magicJS.logger.info("- 充电失败");
  1039. magicJS.logger.info("- 失败原因 " + body?.message);
  1040. }
  1041. } else {
  1042. magicJS.logger.info("- 充电失败");
  1043. magicJS.logger.info("- 失败原因 " + body?.message);
  1044. }
  1045. } catch (e) {
  1046. magicJS.logger.error(e);
  1047. }
  1048. resolve();
  1049. }).catch(err => {
  1050. const msg = `充电异常\n${JSON.stringify(err)}`;
  1051. magicJS.logger.error(msg);
  1052. reject();
  1053. });
  1054. });
  1055. }
  1056. async function me() {
  1057. return new Promise((resolve, reject) => {
  1058. magicJS.logger.info("#### 用户信息");
  1059. const myRequest = {
  1060. url: 'https://api.bilibili.com/x/web-interface/nav',
  1061. headers: {
  1062. "cookie": config.cookieStr
  1063. }
  1064. };
  1065. magicJS.http.get(myRequest).then(response => {
  1066. try {
  1067. const body = response.body;
  1068. if (body?.code) {
  1069. magicJS.logger.info("- ❌❌获得用户信息失败(请更新cookie)");
  1070. magicJS.data.write("bilibili_daily_bonus", null);
  1071. resolve(false);
  1072. } else {
  1073. magicJS.logger.info("- 🎉cookie有效任务即将开始🎉");
  1074. config.user = body?.data;
  1075. config.user.num = check("user") ? 1 : (config.user.num || 0) + 1;
  1076. magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
  1077. config.user.mext_exp = config.user.level_info.next_exp - config.user.level_info.current_exp;
  1078. config.user.next_day = Math.ceil(config.user.mext_exp / 15);
  1079. config.user.v6_exp = 28800 - config.user.level_info.current_exp;
  1080. config.user.v6_day = Math.ceil(config.user.v6_exp / 15);
  1081. if (config.user.vipStatus === 1) {
  1082. magicJS.logger.log("- 💖尊贵的大会员用户💖");
  1083. }
  1084. magicJS.logger.log("- 用户名称: " + config.user.uname);
  1085. magicJS.logger.log("- 用户ID: " + config.user.mid);
  1086. magicJS.logger.log("- 用户硬币: " + Math.floor(config.user.money));
  1087. magicJS.logger.log("- 用户B币: " + config.user.wallet.bcoin_balance);
  1088. magicJS.logger.log("- 用户等级: " + config.user.level_info.current_level);
  1089. magicJS.logger.log(
  1090. `- 当前经验: ${config.user.level_info.current_exp}/${config.user.level_info.next_exp}`
  1091. );
  1092. magicJS.logger.log(`- 升级还需经验: ${config.user.mext_exp}`);
  1093. magicJS.logger.log(
  1094. `- 距离下级还需: ${config.user.next_day}天(登录 观看 分享)`
  1095. );
  1096. magicJS.logger.log(
  1097. `- 距离满级还需: ${Math.max(0, config.user.v6_day)}天(登录 观看 分享)`
  1098. );
  1099. magicJS.logger.log(`- 剩余硬币最多可投: ${Math.floor((config.user.money)/5)}天`);
  1100. magicJS.logger.log(
  1101. "- 距离满级最快还需: " +
  1102. Math.max(0, Math.ceil(config.user.v6_exp / 65)) +
  1103. "天(日常 + 投币*5)"
  1104. );
  1105. resolve(true);
  1106. }
  1107. } catch (e) {
  1108. magicJS.logger.error(JSON.stringify(e));
  1109. resolve();
  1110. }
  1111. }, reason => {
  1112. magicJS.notification.post(magicJS.scriptName, "- 获取用户信息失败", magicJS.toStr(reason));
  1113. resolve(false);
  1114. }).catch(err => {
  1115. const msg = `用户信息异常\n${JSON.stringify(err)}`;
  1116. magicJS.logger.error(msg);
  1117. reject();
  1118. });
  1119. });
  1120. }
  1121. async function queryStatus() {
  1122. return new Promise((resolve, reject) => {
  1123. magicJS.logger.info("#### 检查任务进行状况");
  1124. const myRequest = {
  1125. url: "https://api.bilibili.com/x/member/web/exp/reward",
  1126. headers: {
  1127. "cookie": config.cookieStr
  1128. }
  1129. };
  1130. magicJS.http.get(myRequest).then(response => {
  1131. try {
  1132. const body = response.body;
  1133. if (body?.code === 0) {
  1134. if (body.data.login) {
  1135. magicJS.logger.info("- 今日已登录");
  1136. config.user.num = (config.user.num === 0 ? 1 : config.user.num);
  1137. if (!config['user'].hasOwnProperty("time")) {
  1138. config.user.time = startTime;
  1139. }
  1140. } else {
  1141. magicJS.logger.info("! 今日尚未登录");
  1142. config.user.num = 0;
  1143. }
  1144. if (body.data.watch){
  1145. magicJS.logger.info("- 今日已观看");
  1146. config.watch.num = (config.watch.num === 0 || typeof config.watch.num === 'undefined' ? 1 : config.watch.num);
  1147. if (!config['watch'].hasOwnProperty("time")) {
  1148. config.watch.time = startTime;
  1149. }
  1150. } else {
  1151. magicJS.logger.info("! 今日尚未观看");
  1152. config.watch.num = 0;
  1153. }
  1154. if (body.data.share){
  1155. magicJS.logger.info("- 今日已分享");
  1156. config.share.num = (config.share.num === 0 || typeof config.share.num === 'undefined' ? 1 : config.share.num);
  1157. if (!config['share'].hasOwnProperty("time")) {
  1158. config.share.time = startTime;
  1159. }
  1160. } else {
  1161. magicJS.logger.info("! 今日尚未分享");
  1162. config.share.num = 0;
  1163. }
  1164. if (body.data.coins === 50){
  1165. magicJS.logger.info("- 今日已投币")
  1166. if (!config['coins'].hasOwnProperty("time")) {
  1167. config.coins.time = startTime;
  1168. } else {
  1169. if (format(new Date().toDateString()) > config.coins.time) {
  1170. config.coins.time = startTime;
  1171. }
  1172. }
  1173. } else if ((body.data.coins / 10) >= real_times) {
  1174. config.coins.time = startTime;
  1175. magicJS.logger.info("- 已完成用户设置的投币量");
  1176. } else if (config.user.money <= 5) {
  1177. magicJS.logger.info("! 硬币数不足");
  1178. } else {
  1179. magicJS.logger.info("! 今日投币未完成");
  1180. }
  1181. config.coins.num = body.data.coins;
  1182. magicJS.data.write("bilibili_daily_bonus", magicJS.toStr(config));
  1183. } else {
  1184. magicJS.logger.info("- 查询失败");
  1185. magicJS.logger.info("- 失败原因 " + body?.message);;
  1186. }
  1187. } catch (e) {
  1188. magicJS.logger.error(e);
  1189. }
  1190. resolve();
  1191. }).catch(err => {
  1192. const msg = `检查任务进行状况异常\n${JSON.stringify(err)}`;
  1193. magicJS.logger.error(msg);
  1194. reject();
  1195. });
  1196. });
  1197. }
  1198. async function dynamic() {
  1199. return new Promise((resolve, reject) => {
  1200. magicJS.logger.info("#### 获取首页视频");
  1201. const myRequest = {
  1202. url: `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${config.cookie.DedeUserID}&type_list=8&from=&platform=web`,
  1203. headers: {
  1204. "cookie": config.cookieStr
  1205. }
  1206. };
  1207. magicJS.http.get(myRequest).then(response => {
  1208. try {
  1209. const body = response.body;
  1210. if (body?.data?.cards) {
  1211. cards = body.data.cards;
  1212. const { user, watch, share } = config;
  1213. user.time = watch.time = share.time = startTime;
  1214. magicJS.logger.info("- 获取视频动态成功");
  1215. } else {
  1216. magicJS.logger.info("- 获取视频动态失败");
  1217. }
  1218. } catch (e) {
  1219. magicJS.logger.error(JSON.stringify(e));
  1220. }
  1221. resolve();
  1222. }).catch(err => {
  1223. const msg = `获取首页视频异常\n${JSON.stringify(err)}`;
  1224. magicJS.logger.error(msg);
  1225. reject();
  1226. });
  1227. });
  1228. }
  1229. // Wbi签名获取
  1230. function getWbiSigns(requestParams) {
  1231. // 从给定字符串生成特定的签名
  1232. function generateSignature(baseString) {
  1233. let signature = "";
  1234. signatureIndices.forEach(index => {
  1235. signature += baseString[index];
  1236. });
  1237. return signature.slice(0, 32);
  1238. }
  1239. // 主要函数来构建请求参数并生成最终的请求字符串
  1240. function buildRequestWithSignature(params, imageKey, subscriptionKey) {
  1241. const signatureBase = generateSignature(imageKey + subscriptionKey);
  1242. const startTimeInMillisecond = new Date().getTime();
  1243. const startTimeInSeconds = parseInt(startTimeInMillisecond / 1000);
  1244. let queryString = "";
  1245. // 添加时间戳到请求参数
  1246. params = Object.assign(params, {
  1247. wts: startTimeInSeconds
  1248. });
  1249. // 将参数对象转换为排序后的查询字符串
  1250. queryString = objectToQueryString(sortedObjectEntries(params));
  1251. // 生成请求ID并附加到查询字符串
  1252. const requestId = md5(queryString + signatureBase);
  1253. return queryString + "&w_rid=" + requestId;
  1254. }
  1255. // 转换对象为查询字符串
  1256. function objectToQueryString(obj) {
  1257. return magicJS.objToQueryStr(Object.fromEntries(new Map(Array.from(Object.entries(obj)).sort())));
  1258. }
  1259. // 获取图片和订阅的关键信息
  1260. function getImageAndSubscriptionKeys() {
  1261. const imageUrl = config.user.wbi_img.img_url;
  1262. const subscriptionUrl = config.user.wbi_img.sub_url;
  1263. return {
  1264. img_key: imageUrl.substring(imageUrl.lastIndexOf("/") + 1).split(".")[0],
  1265. sub_key: subscriptionUrl.substring(subscriptionUrl.lastIndexOf("/") + 1).split(".")[0]
  1266. };
  1267. }
  1268. // 签名索引数组
  1269. const signatureIndices = [
  1270. 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39,
  1271. 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63,
  1272. 57, 62, 11, 36, 20, 34, 44, 52
  1273. ];
  1274. // 提取图片和订阅关键信息
  1275. const { img_key, sub_key } = getImageAndSubscriptionKeys();
  1276. // 构建并返回请求字符串,包含签名
  1277. return buildRequestWithSignature(requestParams, img_key, sub_key);
  1278. }
  1279. Main()
  1280. .catch((e) => magicJS.logger.error(`Error: ${JSON.stringify(e)}`))
  1281. .finally(() => magicJS.done());
  1282. //---SyncByPyScript---MagicJS3-start
  1283. function MagicJS(e="MagicJS",t="INFO"){const r=()=>{const e="undefined"!=typeof $loon,t="undefined"!=typeof $task,n="undefined"!=typeof module,r="undefined"!=typeof $httpClient&&!e,o="undefined"!=typeof $storm,i="undefined"!=typeof $environment&&void 0!==$environment["stash-build"];var s=r||e||o||i;const a="undefined"!=typeof importModule;return{isLoon:e,isQuanX:t,isNode:n,isSurge:r,isStorm:o,isStash:i,isSurgeLike:s,isScriptable:a,get name(){return e?"Loon":t?"QuantumultX":n?"NodeJS":r?"Surge":a?"Scriptable":"unknown"},get build(){return r?$environment["surge-build"]:i?$environment["stash-build"]:o?$storm.buildVersion:void 0},get language(){if(r||i)return $environment.language},get version(){return r?$environment["surge-version"]:i?$environment["stash-version"]:o?$storm.appVersion:n?process.version:void 0},get system(){return r?$environment.system:n?process.platform:void 0},get systemVersion(){if(o)return $storm.systemVersion},get deviceName(){if(o)return $storm.deviceName}}},o=(n,e="INFO")=>{let r=e,t="\n";const o={SNIFFER:6,DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1},i={SNIFFER:"",DEBUG:"",INFO:"",NOTIFY:"",WARNING:"❗ ",ERROR:"❌ ",CRITICAL:"❌ ",NONE:""},s=(e,t="INFO")=>{o[r]<o[t.toUpperCase()]||console.log(`██[${n}][${t}]`+i[t.toUpperCase()]+e+"\n")};return{getLevel:()=>r,setLevel:e=>{r=e},sniffer:(...e)=>{e=e.join(t);s(e,"SNIFFER")},log:(...e)=>{e=e.join(t);console.log(`██[${n}]`+e+"\n")},debug:(...e)=>{e=e.join(t);s(e,"DEBUG")},info:(...e)=>{e=e.join(t);s(e,"INFO")},notify:(...e)=>{e=e.join(t);s(e,"NOTIFY")},warning:(...e)=>{e=e.join(t);s(e,"WARNING")},error:(...e)=>{e=e.join(t);s(e,"ERROR")},retry:(...e)=>{e=e.join(t);s(e,"RETRY")}}};return new class{constructor(e,t){var n;this._startTime=Date.now(),this.version="3.0.0",this.scriptName=e,this.env=r(),this.logger=o(e,t),this.http="function"==typeof MagicHttp?MagicHttp(this.env,this.logger):void 0,this.data="function"==typeof MagicData?MagicData(this.env,this.logger):void 0,this.notification="function"==typeof MagicNotification?MagicNotification(this.scriptName,this.env,this.logger,this.http):void 0,this.utils="function"==typeof MagicUtils?MagicUtils(this.env,this.logger):void 0,this.qinglong="function"==typeof MagicQingLong?MagicQingLong(this.env,this.data,this.logger):void 0,void 0!==this.data&&(t=this.data.read("magic_loglevel"),n=this.data.read("magic_bark_url"),t&&this.logger.setLevel(t.toUpperCase()),n)&&this.notification.setBark(n),this.logger.info(e+", 开始执行!")}get isRequest(){return"undefined"!=typeof $request}get isStrictRequest(){return"undefined"!=typeof $request&&"undefined"==typeof $response}get isResponse(){return"undefined"!=typeof $response}get isDebug(){return"DEBUG"===this.logger.level}get request(){return"undefined"!=typeof $request?$request:void 0}get response(){if("undefined"!=typeof $response)return $response.hasOwnProperty("status")&&($response.statusCode=$response.status),$response.hasOwnProperty("statusCode")&&($response.status=$response.statusCode),$response}toStr(e,t=null){try{return JSON.stringify(e)}catch{return t}}toObj(e,t=null){try{return JSON.parse(e)}catch{return t}}checkRecordRequestBody(){if(this.isRequest){var t=$request.body;if(t){var n=this.env,r=$request.path;let e=this.scriptName+"#"+r.replace("/","_");e=e.replace("?","#"),n.isQuanX&&$prefs.setValueForKey(t,e),(n.isLoon||n.isSurge)&&$persistentStore.write(t,e),n.isNode&&require("fs").writeFileSync(e+".json",t,{flag:"w"},e=>console.log(e))}}}getRequestBody(){var e=this.env,t=$request.path;let n=this.scriptName+"#"+t.replace("/","_");if(n=n.replace("?","#"),e.isSurge||e.isLoon)return $persistentStore.read(n);if(e.isQuanX)return $prefs.valueForKey(n);if(e.isNode){t=n+".json",e=require("fs");if(!e.existsSync(t))return JSON.parse(e.readFileSync(t))}}getResponseBody(){if($response)return $response.body}parseCookies(e){let t={};return e&&e.split(";").forEach(function(e){e=e.split("=");t[e.shift().trim()]=decodeURI(e.join("="))}),t}serializeCookies(e){var t,n=[];for(t in e){var r=e[t],r=encodeURIComponent(t)+"="+encodeURIComponent(r);n.push(r)}return n.join("; ")}parseSetCookies(e){const o=["Expires","Max-Age","Domain","Path","HttpOnly","SameSite"];e=e.split(";");let i=null;const s={},a=[];return e.forEach(e=>{var t,e=e.trim();let n=null,r=!0;if(e.includes("=")?(t=e.split("="),n=t[0].trim(),r=t[1].trim()):n=e,o.includes(n))s[i]&&(s[i][n]=r,s[i].attribs[n]=r);else{i=n;let t={};i.includes(",")&&i.split(",").forEach(e=>{e=e.trim();o.includes(e)?t[e]=!0:i=e}),s[i]={name:i,value:r,attribs:t},a.push(s[i])}}),a}objToQueryStr(t,n){let r="";for(const o in t){let e=t[o];null!=e&&""!==e&&("object"==typeof e?e=JSON.stringify(e):n&&(e=encodeURIComponent(e)),r+=`${o}=${e}&`)}return r=r.substring(0,r.length-1)}parseQueryStr(e){var t={},n=(e=-1<e.indexOf("?")?e.split("?")[1]:e).split("&");for(let e=0;e<n.length;e++){var r=n[e].split("=");t[r[0]]=r[1]}return t}deepClone(e,t){for(var n in t=t||{},e)"object"==typeof e[n]?(t[n]=e[n].constructor===Array?[]:{},this.deepClone(e[n],t[n])):t[n]=e[n];return t}formatDate(e,t){var n,r={"M+":e.getMonth()+1,"d+":e.getDate(),"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(n in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+n+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?r[n]:("00"+r[n]).substr((""+r[n]).length)));return t}parseDate(a,e){let l={y:0,M:1,d:0,H:0,h:0,m:0,s:0,S:0};(e=e||"yyyy-MM-dd").replace(/([^yMdHmsS]*?)(([yMdHmsS])\3*)([^yMdHmsS]*?)/g,function(e,t,n,r,o,i,s){return a=a.replace(new RegExp(t+"(\\d{"+n.length+"})"+o),function(e,t){return l[r]=parseInt(t),""}),""}),l.M--;e=new Date(l.y,l.M,l.d,l.H,l.m,l.s);return 0!==l.S&&e.setMilliseconds(l.S),e}costTime(){var e=this.scriptName+"执行完毕!",t=(this._endTime=(new Date).getTime(),this._endTime-this._startTime);this.logger.info(e+`耗时【${t/1e3}】秒`)}done=(e={})=>{this.costTime(),"undefined"!=typeof $done&&$done(e)}}(e,t)}function MagicHttp(d,g){var e;let p;d.isNode&&(e=require("axios"),p=e.create());class t{constructor(e=!0){this.handlers=[],this.isRequest=e}use(e,t,n){return"function"==typeof e&&g.debug("Register fulfilled "+e.name),"function"==typeof t&&g.debug("Register rejected "+t.name),this.handlers.push({fulfilled:e,rejected:t,synchronous:!(!n||"boolean"!=typeof n.synchronous)&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}forEach(t){this.handlers.forEach(e=>{null!==e&&t(e)})}}function f(e){let n={...e};return n.params&&!d.isNode&&(e=Object.keys(n.params).map(e=>{var t=encodeURIComponent(e);return n.url=n.url.replace(new RegExp(e+"=[^&]*","ig"),""),n.url=n.url.replace(new RegExp(t+"=[^&]*","ig"),""),t+"="+encodeURIComponent(n.params[e])}).join("&"),n.url.indexOf("?")<0&&(n.url+="?"),/(&|\?)$/g.test(n.url)||(n.url+="&"),n.url+=e,delete n.params,g.debug("Params to QueryString: "+n.url)),n}const y=(e,t=null)=>{if(e){t={...e,config:e.config||t,status:e.statusCode||e.status,body:e.body||e.data,headers:e.headers||e.header};if("string"==typeof t.body)try{t.body=JSON.parse(t.body)}catch{}return delete t.data,t}return e};const h=(e,t=null)=>{if(e&&400<=e.status)return g.debug("Raise exception when status code is "+e.status),{name:"RequestException",message:"Request failed with status code "+e.status,config:t||e.config,response:e}},m={request:new t,response:new t(!1)};let v=[],b=[],S=!0;function N(e){return e=f(e),g.debug(`HTTP ${e.method.toUpperCase()}:`+"\n"+JSON.stringify(e)),e}function E(t){try{t=t&&y(t),g.sniffer(`HTTP ${t.config.method.toUpperCase()}:`+"\n"+JSON.stringify(t.config)+"\nSTATUS CODE:\n"+t.status+"\nRESPONSE:\n"+("object"==typeof t.body?JSON.stringify(t.body):t.body));var e=h(t);return e?Promise.reject(e):t}catch(e){return g.error(e),t}}const n=(e,n)=>{let r;n=((e,t)=>{let n="object"==typeof t?{headers:{},...t}:{url:t,headers:{}};return n.method||(n.method=e),!0===(n=f(n)).rewrite&&(d.isSurge?(n.headers["X-Surge-Skip-Scripting"]=!1,delete n.rewrite):d.isQuanX&&(n.hints=!1,delete n.rewrite)),d.isSurgeLike?(t=n.headers["content-type"]||n.headers["Content-Type"],"GET"!==n.method&&t&&0<=t.indexOf("application/json")&&n.body instanceof Array&&(n.body=JSON.stringify(n.body),g.debug("Convert Array object to String: "+n.body))):d.isQuanX?(n.hasOwnProperty("body")&&"string"!=typeof n.body&&(n.body=JSON.stringify(n.body)),n.method=e):d.isNode&&("POST"===e||"PUT"===e||"PATCH"===e||"DELETE"===e?n.data=n.data||n.body:"GET"===e&&(n.params=n.params||n.body),delete n.body),n})(e.toUpperCase(),n),r=d.isNode?p:d.isSurgeLike?i=>new Promise((r,o)=>{$httpClient[e.toLowerCase()](i,(e,t,n)=>{e?(e={name:e.name||e,message:e.message||e,stack:e.stack||e,config:i,response:y(t)},o(e)):(t.config=i,t.body=n,r(t))})}):r=>new Promise((n,t)=>{$task.fetch(r).then(e=>{e=y(e,r);var t=h(e,r);if(t)return Promise.reject(t);n(e)}).catch(e=>{e={name:e.message||e.error,message:e.message||e.error,stack:e.error,config:r,response:e.response?y(e.response):null};t(e)})});let o;var t=n;try{v=[],b=[],m.request.forEach(e=>{"function"==typeof e.runWhen&&!1===e.runWhen(t)||(S=S&&e.synchronous,v.unshift(e.fulfilled,e.rejected))}),m.response.forEach(e=>{b.push(e.fulfilled,e.rejected)})}catch(e){g.error(`Failed to register interceptors: ${e}.`)}var i=[N,void 0],s=[E,void 0];if(S){for(g.debug("Interceptors are executed in synchronous mode"),Array.prototype.unshift.apply(v,i),v=v.concat([N,void 0]);v.length;){var a=v.shift(),l=v.shift();try{"function"==typeof a&&g.debug("Executing request fulfilled "+a.name),n=a(n)}catch(e){"function"==typeof l&&g.debug("Executing request rejected "+l.name),l(e);break}}try{o=(!d.isNode&&n.timeout?c:r)(n)}catch(e){return Promise.reject(e)}for(Array.prototype.unshift.apply(b,s);b.length;)o=o.then(b.shift(),b.shift());return o}{g.debug("Interceptors are executed in asynchronous mode");let t=[r,void 0];for(Array.prototype.unshift.apply(t,i),Array.prototype.unshift.apply(t,v),t=(t=t.concat(s)).concat(b),o=Promise.resolve(n);t.length;)try{let e=t.shift();var u=t.shift();"function"==typeof(e=!d.isNode&&n.timeout&&e===r?c:e)&&g.debug("Executing request fulfilled "+e.name),"function"==typeof u&&g.debug("Executing request rejected "+u.name),o=o.then(e,u)}catch(e){g.error("request exception: "+e)}return o}function c(n){try{var e=new Promise((e,t)=>{setTimeout(()=>{var e={message:`timeout of ${n.timeout}ms exceeded.`,config:n};t(e)},n.timeout)});return Promise.race([r(n),e])}catch(e){g.error(`Request Timeout exception: ${e}.`)}}};return{request:n,interceptors:m,convertHeadersToLowerCase:n=>Object.keys(n).reduce((e,t)=>(e[t.toLowerCase()]=n[t],e),{}),convertHeadersToCamelCase:n=>Object.keys(n).reduce((e,t)=>{return e[t.split("-").map(e=>e[0].toUpperCase()+e.slice(1)).join("-")]=n[t],e},{}),modifyResponse:y,get:e=>n("GET",e),post:e=>n("POST",e),put:e=>n("PUT",e),patch:e=>n("PATCH",e),delete:e=>n("DELETE",e),head:e=>n("HEAD",e),options:e=>n("OPTIONS",e)}}function MagicData(d,g){let p={fs:void 0,data:{}};if(d.isNode){p.fs=require("fs");try{p.fs.accessSync("./magic.json",p.fs.constants.R_OK|p.fs.constants.W_OK)}catch(e){p.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}p.data=require("./magic.json")}const s=(e,t)=>"object"!=typeof t&&e===t,a=e=>"true"===e||"false"!==e&&(void 0===e?null:e),l=(e,t,n,r)=>{if(n)try{e=!0===(e="string"==typeof e?JSON.parse(e):e).magic_session?e[n]:null}catch{e=null}if("string"==typeof e&&"null"!==e)try{e=JSON.parse(e)}catch{}return null==(e=!1===r&&e&&!0===e.magic_session?null:e)&&null!=t&&(e=t),e=a(e)},f=t=>{if("string"!=typeof t)return t instanceof Array||null==t||t!=t||"boolean"==typeof t?{}:t;{let e={};try{var n=typeof(e=JSON.parse(t));("object"!=n||e instanceof Array||"bool"==n||null===e)&&(e={})}catch{}return e}},u=(e,t=null,n="",r=!1,o=null)=>{let i="";return i=o||d.isNode?((e,t=null,n="",r=!1,o=null)=>{o=o||p.data;return val=o&&void 0!==o[e]&&null!==o[e]?o[e]:n?{}:null,val=l(val,t,n,r)})(e,t,n,r,o):(d.isSurgeLike?i=$persistentStore.read(e):d.isQuanX&&(i=$prefs.valueForKey(e)),l(i,t,n,r)),g.debug(`READ DATA [${e}]${n?`[${n}]`:""} <${typeof i}>`+"\n"+JSON.stringify(i)),i},c=(e,t,n="",r=null)=>{if(void 0===t||t!=t)return!1;d.isNode||"boolean"!=typeof t&&"number"!=typeof t||(t=String(t));let o="";var i,s,a,l,u,c;if(r||d.isNode?o=([i,s,a="",l=null]=[e,t,n,r],c=l||p.data,c=f(c),a?((u=f(c[i])).magic_session=!0,u[a]=s,c[i]=u):c[i]=s,null!==l&&(l=c),c):n?(d.isSurgeLike?o=$persistentStore.read(e)?$persistentStore.read(e):o:d.isQuanX&&(o=$prefs.valueForKey(e)?$prefs.valueForKey(e):o),(o=f(o)).magic_session=!0,o[n]=t):o=t,o&&"object"==typeof o&&(o=JSON.stringify(o,null,4)),g.debug(`WRITE DATA [${e}]${n?`[${n}]`:""} <${typeof t}>`+"\n"+JSON.stringify(t)),!r){if(d.isSurgeLike)return $persistentStore.write(o,e);if(d.isQuanX)return $prefs.setValueForKey(o,e);if(d.isNode)try{p.fs.writeFileSync("./magic.json",o)}catch(e){return g.error(e),!1}}return!0};return{read:u,write:c,del:(e,t="",n=null)=>{let r={};if(n||d.isNode)r=(o=e,i=t,s=n||p.data,s=f(s),i?(delete(obj=f(s[o]))[i],s[o]=obj):delete s[o],s),n?n=r:p.fs.writeFileSync("./magic.json",JSON.stringify(r,null,4));else if(t){d.isSurgeLike?r=$persistentStore.read(e):d.isQuanX&&(r=$prefs.valueForKey(e)),delete(r=f(r))[t];i=JSON.stringify(r,null,4);c(e,i)}else{if(d.isStorm)return $persistentStore.remove(e);if(d.isSurgeLike)return $persistentStore.write(null,e);if(d.isQuanX)return $prefs.removeValueForKey(e)}var o,i,s;g.debug(`DELETE KEY [${e}]`+(t?`[${t}]`:""))},update:(e,t,n,r=s,o=null)=>{var i;return t=a(t),!0!==r(u(e,null,n,!1,o),t)&&(i=c(e,t,n,o),e=u(e,null,n,!1,o),r===s&&"object"==typeof e?i:r(t,e))},allSessions:(e,t=null)=>{let n={};t=u(e,null,null,!0,t);return!0===(t=f(t)).magic_session&&delete(n={...t}).magic_session,g.debug(`READ ALL SESSIONS [${e}] <${typeof n}>`+"\n"+JSON.stringify(n,null,4)),n},allSessionNames:(e,t=null)=>{let n=[];t=u(e,null,null,!0,t),t=f(t);return n=!0!==t.magic_session?[]:Object.keys(t).filter(e=>"magic_session"!==e),g.debug(`READ ALL SESSIONS [${e}] <${typeof n}>`+"\n"+JSON.stringify(n,null,4)),n},defaultValueComparator:s,convertToObject:f}}function MagicNotification(i,o,s,a){let l=null,u=null,c=[];function d(e=i,t="",n="",r=""){r=(t=>{try{let e={};var n;return"string"==typeof t?0<t.length&&(o.isLoon?e={openUrl:t}:o.isQuanX?e={"open-url":t}:o.isSurge&&(e={url:t})):"object"==typeof t&&(o.isLoon?(e.openUrl=t["open-url"]||"",e.mediaUrl=t["media-url"]||""):o.isQuanX?e=t["open-url"]||t["media-url"]?t:{}:o.isSurge&&(n=t["open-url"]||t.openUrl,e=n?{url:n}:{})),e}catch(e){s.error("通知选项转换失败"+e)}return t})(r),1===arguments.length&&(e=i,t="",n=arguments[0]),s.notify("\ntitle:"+e+"\nsubTitle:"+t+"\nbody:"+n+"\noptions:"+("object"==typeof r?JSON.stringify(r):r)),o.isSurge?$notification.post(e,t,n,r):o.isLoon?r?$notification.post(e,t,n,r):$notification.post(e,t,n):o.isQuanX&&$notify(e,t,n,r),l&&u&&g(e,t,n)}function g(e=i,t="",n="",r){if(void 0===a||void 0===a.post)throw"Bark notification needs to import MagicHttp module.";e={url:l,headers:{"content-type":"application/json; charset=utf-8"},body:{title:e,body:t?t+"\n"+n:n,device_key:u}};a.post(e).catch(e=>{s.error("Bark notify error: "+e)})}return{post:d,debug:function(e=i,t="",n="",r=""){"DEBUG"===s.getLevel()&&(1===arguments.length&&(e=i,t="",n=arguments[0]),this.post(e,t,n,r))},bark:g,setBark:e=>{try{var t=e.replace(/\/+$/g,"");l=/^https?:\/\/([^/]*)/.exec(t)[0]+"/push",u=/\/([^\/]+)\/?$/.exec(t)[1]}catch(e){s.error(`Bark url error: ${e}.`)}},appendNotifyInfo:function(e,t){1==t?c=e:c.push(e)},prependNotifyInfo:function(e){c.splice(0,0,e)},msg:function(e,t,n,r){var o={};n&&(o["open-url"]=n),r&&(o["media-url"]=r),(t=t&&0!=t.length?t:Array.isArray(c)?c.join("\n"):c)&&0<t.length&&d(i,"",t,o)}}}function MagicUtils(r,u){const e=(e,t="yyyy-MM-dd hh:mm:ss")=>{var n,r={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(n in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+n+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?r[n]:("00"+r[n]).substr((""+r[n]).length)));return t};return{retry:(i,s=5,a=0,l=null)=>(...e)=>new Promise((n,r)=>{function o(...t){Promise.resolve().then(()=>i.apply(this,t)).then(e=>{"function"==typeof l?Promise.resolve().then(()=>l(e)).then(()=>{n(e)}).catch(e=>{1<=s?0<a?setTimeout(()=>o.apply(this,t),a):o.apply(this,t):r(e),s--}):n(e)}).catch(e=>{u.error(e),1<=s&&0<a?setTimeout(()=>o.apply(this,t),a):1<=s?o.apply(this,t):r(e),s--})}o.apply(this,e)}),formatTime:e,now:()=>e(new Date,"yyyy-MM-dd hh:mm:ss"),today:()=>e(new Date,"yyyy-MM-dd"),sleep:t=>new Promise(e=>setTimeout(e,t)),assert:(e,t=null)=>{var n;r.isNode?(n=require("assert"),t?n(e,t):n(e)):!0!==e&&u.error("AssertionError: "+(t||"The expression evaluated to a falsy value."))}}}function MagicQingLong(e,a,o){let i="",s="",l="",u="",c="",t="";const d="magic.json",g=MagicHttp(e,o);async function n(){return l=l||a.read("magic_qlclient"),u=u||a.read("magic_qlsecrt"),s=s||a.read("magic_qlname"),c=c||a.read("magic_qlpwd"),i&&l&&u?(o.info("Get token from QingLong Panel"),await g.get({url:"/open/auth/token",headers:{"content-type":"application/json"},params:{client_id:l,client_secret:u}}).then(e=>{if(!(0<Object.keys(e.body).length&&e.body.data&&e.body.data.token))throw new Error("Get QingLong Panel token failed.");o.info("Successfully logged in to QingLong Panel"),t=e.body.data.token,a.write("magic_qltoken",t)}).catch(e=>{o.error("Error logging in to QingLong Panel.\n"+(e.message||e))})):i&&s&&c&&await g.post({url:"/api/user/login",headers:{"content-type":"application/json"},body:{username:s,password:c}}).then(e=>{o.info("Successfully logged in to QingLong Panel"),t=e.body.data.token,a.write("magic_qltoken",t)}).catch(e=>{o.error("Error logging in to QingLong Panel.\n"+(e.message||e))}),t}async function p(e){let t=[];return await g.post({url:"/api/envs",headers:{"content-type":"application/json"},body:e}).then(e=>{200===e.body.code?e.body.data.forEach(e=>{o.debug(`QINGLONG ADD ENV ${e.name} <${typeof e.value}> (${e.id})`+"\n"+JSON.stringify(e)),t.push(e.id)}):o.error("Error adding environments variable from QingLong Panel.\n"+JSON.stringify(e))}).catch(e=>{o.error("Error adding environments variable from QingLong Panel.\n"+(e.message||e))}),t}async function r(r=null,e="",t){let o=[];return await g.get({url:"/api/envs",headers:{"content-type":"application/json"},params:{searchValue:e}}).then(e=>{if(200!==e.body.code)throw new Error("Error reading environment variable from QingLong Panel.\n"+JSON.stringify(e));e=e.body.data;if(r){var t=[];for(const n of e)n.name===r&&o.push(n);o=t}o=e}).catch(e=>{throw new Error("Error reading environments variable from QingLong Panel.\n"+(e.message||e))}),o}async function f(e,t=""){let n="";return await g.get({url:"/api/scripts/"+e,params:{path:t}}).then(e=>{if(200!==e.body.code)throw new Error("Error reading data from QingLong Panel.\n"+JSON.stringify(e));n=e.body.data}).catch(e=>{throw new Error("Error reading data from QingLong Panel.\n"+(e.message||e))}),n}async function y(e,t="",n=""){let r=!1;return await g.put({url:"/api/scripts",headers:{"content-type":"application/json"},body:{filename:e,path:t,content:n}}).then(e=>{200===e.body.code?r=!0:o.error("Error reading data from QingLong Panel.\n"+JSON.stringify(e))}).catch(e=>{o.error("Error reading data from QingLong Panel.\n"+(e.message||e))}),r}return g.interceptors.request.use(function(e){return i=i||a.read("magic_qlurl"),e.url.indexOf(i)<0&&(e.url=""+i+e.url),{...e,timeout:3e3}},void 0),g.interceptors.request.use(function(e){return(l=l||a.read("magic_qlclient"))&&(e.url=e.url.replace("/api/","/open/")),e},void 0,{runWhen:e=>e.url.indexOf("api/user/login")<0&&e.url.indexOf("open/auth/token")<0}),g.interceptors.request.use(async function(e){return(t=t||a.read("magic_qltoken",""))||await n(),e.headers.authorization="Bearer "+t,e},void 0,{runWhen:e=>e.url.indexOf("api/user/login")<0&&e.url.indexOf("open/auth/token")<0}),g.interceptors.request.use(function(e){return e.params={...e.params,t:Date.now()},e},void 0,{runWhen:e=>e.url.indexOf("open/auth/token")<0}),g.interceptors.request.use(function(e){return i=i||a.read("magic_qlurl"),t=t||a.read("magic_qltoken"),o.debug("QingLong url: "+i+"\nQingLong token: "+t),e},void 0),g.interceptors.response.use(void 0,async function(e){try{var t=e.message||e.error||JSON.stringify(e);return(0<=t.indexOf("NSURLErrorDomain")&&0<=t.indexOf("-1012")||e.response&&401===e.response.status)&&e.config&&!0!==e.config.refreshToken?(o.warning("QingLong Panel token has expired"),o.info("Refreshing the QingLong Panel token"),await n(),e.config.refreshToken=!0,o.info("Call the previous method again"),await g.request(e.config.method,e.config)):Promise.reject(e)}catch(e){return Promise.reject(e)}}),{url:i||a.read("magic_qlurl"),init:(e,t,n,r,o)=>{i=e,l=t,u=n,s=r,c=o},getToken:n,setEnv:async function(t,n,r=null){if(i=i||a.read("magic_qlurl"),null===r){var e=await p([{name:t,value:n}]);if(e&&1===e.length)return e[0]}else await g.put({url:"/api/envs",headers:{"content-type":"application/json"},body:{name:t,value:n,id:r}}).then(e=>{if(200===e.body.code)return o.debug(`QINGLONG UPDATE ENV ${t} <${typeof n}> (${r})`+"\n"+JSON.stringify(n)),!0;o.error("Error adding environment variable from QingLong Panel.\n"+JSON.stringify(e))}).catch(e=>(o.error("Error adding environment variable from QingLong Panel.\n"+(e.message||e)),!1))},setEnvs:p,getEnv:async function(e){let t=null;for(const n of await r())if(n.id===e){t=n;break}return t},getEnvs:r,delEnvs:async function(t){return g.delete({url:"/api/envs",headers:{accept:"application/json","accept-language":"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",connection:"keep-alive","content-type":"application/json;charset=UTF-8","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36 Edg/102.0.1245.30"},body:t}).then(e=>200===e.body.code?(o.debug("QINGLONG DELETE ENV IDS: "+t),!0):(o.error("Error deleting environments variable from QingLong Panel.\n"+JSON.stringify(e)),!1)).catch(e=>{o.error("Error deleting environments variable from QingLong Panel.\n"+(e.message||e))})},disableEnvs:async function(t){let n=!1;return await g.put({url:"/api/envs/disable",headers:{accept:"application/json","accept-Language":"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",connection:"keep-alive","content-type":"application/json;charset=UTF-8","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36 Edg/102.0.1245.30"},body:t}).then(e=>{200===e.body.code?(o.debug("QINGLONG DISABLED ENV IDS: "+t),n=!0):o.error("Error disabling environments variable from QingLong Panel.\n"+JSON.stringify(e))}).catch(e=>{o.error("Error disabling environments variable from QingLong Panel.\n"+(e.message||e))}),n},enableEnvs:async function(t){let n=!1;return await g.put({url:"/api/envs/enable",headers:{accept:"application/json","accept-language":"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",connection:"keep-alive","content-type":"application/json;charset=UTF-8","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36 Edg/102.0.1245.30"},body:t}).then(e=>{200===e.body.code?(o.debug("QINGLONG ENABLED ENV IDS: "+t),n=!0):o.error("Error enabling environments variable from Qilong panel.\n"+JSON.stringify(e))}).catch(e=>{o.error("Error enabling environments variable from Qilong panel.\n"+(e.message||e))}),n},addScript:async function(e,t="",n=""){let r=!1;return await g.post({url:"/api/scripts",headers:{"content-type":"application/json"},body:{filename:e,path:t,content:n}}).then(e=>{200===e.body.code?r=!0:o.error("Error reading data from QingLong Panel.\n"+JSON.stringify(e))}).catch(e=>{o.error("Error reading data from QingLong Panel.\n"+(e.message||e))}),r},getScript:f,editScript:y,delScript:async function(e,t=""){let n=!1;return await g.delete({url:"/api/scripts",headers:{"content-type":"application/json"},body:{filename:e,path:t}}).then(e=>{200===e.body.code?n=!0:o.error("Error reading data from QingLong Panel.\n"+JSON.stringify(e))}).catch(e=>{o.error("Error reading data from QingLong Panel.\n"+(e.message||e))}),n},write:async function(e,t,n=""){var r=await f(d,""),o=a.convertToObject(r),e=a.write(e,t,n,o),r=JSON.stringify(o,null,4);return await y(d,"",r)&&e},read:async function(e,t,n="",r=!1){var o=await f(d,""),o=a.convertToObject(o);return a.read(e,t,n,r,o)},del:async function(e,t=""){var n=await f(d,""),r=a.convertToObject(n),e=a.del(e,t,r),n=JSON.stringify(r,null,4),t=await y(d,"",n);return e&&t},update:async function(e,t,n,r=a.defaultValueComparator){var o=await f(d,""),i=a.convertToObject(o),e=a.update(e,t,n,r,i);let s=!1;return!0===e&&(o=JSON.stringify(i,null,4),s=await y(d,"",o)),e&&s},batchWrite:async function(...e){var t,n=await f(d,""),r=a.convertToObject(n);for(t of e)a.write(t[0],t[1],void 0!==t[2]?t[2]:"",r);return n=JSON.stringify(r,null,4),y(d,"",n)},batchRead:async function(...e){var t,n=await f(d,""),r=a.convertToObject(n),o=[];for(t of e){var i=a.read(t[0],t[1],void 0!==t[2]?t[2]:"","boolean"==typeof t[3]&&t[3],r);o.push(i)}return o},batchUpdate:async function(...e){var t,n=await f(d,""),r=a.convertToObject(n);for(t of e)a.update(t[0],t[1],void 0!==t[2]?t[2]:"",void 0!==t[3]?t.comparator:a.defaultValueComparator,r);return n=JSON.stringify(r,null,4),y(d,"",n)},batchDel:async function(...e){var t,n=await f(d,""),r=a.convertToObject(n);for(t of e)a.del(t[0],void 0!==t[1]?t[1]:"",r);return n=JSON.stringify(r,null,4),y(d,"",n)},allSessions:async function(e){var t=await f(d,""),t=a.convertToObject(t);return a.allSessions(e,t)},allSessionNames:async function(e){var t=await f(d,""),t=a.convertToObject(t);return a.allSessionNames(e,t)}}}
  1284. //---SyncByPyScript---MagicJS3-end
  1285. //---SyncByPyScript---md5-start
  1286. !function(n){"use strict";function d(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function f(n,t,r,e,o,u){return d((u=d(d(t,n),d(e,u)))<<o|u>>>32-o,r)}function l(n,t,r,e,o,u,c){return f(t&r|~t&e,n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t&e|r&~e,n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function c(n,t){var r,e,o,u;n[t>>5]|=128<<t%32,n[14+(t+64>>>9<<4)]=t;for(var c=1732584193,f=-271733879,i=-1732584194,a=271733878,h=0;h<n.length;h+=16)c=l(r=c,e=f,o=i,u=a,n[h],7,-680876936),a=l(a,c,f,i,n[h+1],12,-389564586),i=l(i,a,c,f,n[h+2],17,606105819),f=l(f,i,a,c,n[h+3],22,-1044525330),c=l(c,f,i,a,n[h+4],7,-176418897),a=l(a,c,f,i,n[h+5],12,1200080426),i=l(i,a,c,f,n[h+6],17,-1473231341),f=l(f,i,a,c,n[h+7],22,-45705983),c=l(c,f,i,a,n[h+8],7,1770035416),a=l(a,c,f,i,n[h+9],12,-1958414417),i=l(i,a,c,f,n[h+10],17,-42063),f=l(f,i,a,c,n[h+11],22,-1990404162),c=l(c,f,i,a,n[h+12],7,1804603682),a=l(a,c,f,i,n[h+13],12,-40341101),i=l(i,a,c,f,n[h+14],17,-1502002290),c=g(c,f=l(f,i,a,c,n[h+15],22,1236535329),i,a,n[h+1],5,-165796510),a=g(a,c,f,i,n[h+6],9,-1069501632),i=g(i,a,c,f,n[h+11],14,643717713),f=g(f,i,a,c,n[h],20,-373897302),c=g(c,f,i,a,n[h+5],5,-701558691),a=g(a,c,f,i,n[h+10],9,38016083),i=g(i,a,c,f,n[h+15],14,-660478335),f=g(f,i,a,c,n[h+4],20,-405537848),c=g(c,f,i,a,n[h+9],5,568446438),a=g(a,c,f,i,n[h+14],9,-1019803690),i=g(i,a,c,f,n[h+3],14,-187363961),f=g(f,i,a,c,n[h+8],20,1163531501),c=g(c,f,i,a,n[h+13],5,-1444681467),a=g(a,c,f,i,n[h+2],9,-51403784),i=g(i,a,c,f,n[h+7],14,1735328473),c=v(c,f=g(f,i,a,c,n[h+12],20,-1926607734),i,a,n[h+5],4,-378558),a=v(a,c,f,i,n[h+8],11,-2022574463),i=v(i,a,c,f,n[h+11],16,1839030562),f=v(f,i,a,c,n[h+14],23,-35309556),c=v(c,f,i,a,n[h+1],4,-1530992060),a=v(a,c,f,i,n[h+4],11,1272893353),i=v(i,a,c,f,n[h+7],16,-155497632),f=v(f,i,a,c,n[h+10],23,-1094730640),c=v(c,f,i,a,n[h+13],4,681279174),a=v(a,c,f,i,n[h],11,-358537222),i=v(i,a,c,f,n[h+3],16,-722521979),f=v(f,i,a,c,n[h+6],23,76029189),c=v(c,f,i,a,n[h+9],4,-640364487),a=v(a,c,f,i,n[h+12],11,-421815835),i=v(i,a,c,f,n[h+15],16,530742520),c=m(c,f=v(f,i,a,c,n[h+2],23,-995338651),i,a,n[h],6,-198630844),a=m(a,c,f,i,n[h+7],10,1126891415),i=m(i,a,c,f,n[h+14],15,-1416354905),f=m(f,i,a,c,n[h+5],21,-57434055),c=m(c,f,i,a,n[h+12],6,1700485571),a=m(a,c,f,i,n[h+3],10,-1894986606),i=m(i,a,c,f,n[h+10],15,-1051523),f=m(f,i,a,c,n[h+1],21,-2054922799),c=m(c,f,i,a,n[h+8],6,1873313359),a=m(a,c,f,i,n[h+15],10,-30611744),i=m(i,a,c,f,n[h+6],15,-1560198380),f=m(f,i,a,c,n[h+13],21,1309151649),c=m(c,f,i,a,n[h+4],6,-145523070),a=m(a,c,f,i,n[h+11],10,-1120210379),i=m(i,a,c,f,n[h+2],15,718787259),f=m(f,i,a,c,n[h+9],21,-343485551),c=d(c,r),f=d(f,e),i=d(i,o),a=d(a,u);return[c,f,i,a]}function i(n){for(var t="",r=32*n.length,e=0;e<r;e+=8)t+=String.fromCharCode(n[e>>5]>>>e%32&255);return t}function a(n){var t=[];for(t[(n.length>>2)-1]=void 0,e=0;e<t.length;e+=1)t[e]=0;for(var r=8*n.length,e=0;e<r;e+=8)t[e>>5]|=(255&n.charCodeAt(e/8))<<e%32;return t}function e(n){for(var t,r="0123456789abcdef",e="",o=0;o<n.length;o+=1)t=n.charCodeAt(o),e+=r.charAt(t>>>4&15)+r.charAt(15&t);return e}function r(n){return unescape(encodeURIComponent(n))}function o(n){return i(c(a(n=r(n)),8*n.length))}function u(n,t){return function(n,t){var r,e=a(n),o=[],u=[];for(o[15]=u[15]=void 0,16<e.length&&(e=c(e,8*n.length)),r=0;r<16;r+=1)o[r]=909522486^e[r],u[r]=1549556828^e[r];return t=c(o.concat(a(t)),512+8*t.length),i(c(u.concat(t),640))}(r(n),r(t))}function t(n,t,r){return t?r?u(t,n):e(u(t,n)):r?o(n):e(o(n))}"function"==typeof define&&define.amd?define(function(){return t}):"object"==typeof module&&module.exports?module.exports=t:n.md5=t}(this);
  1287. //---SyncByPyScript---md5-end