smzdmHelper.js 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. /******************************
  2. > 什么值得买每日签到和任务
  3. *******************************
  4. [rewrite_local]
  5. ^https?:\/\/user-api\.smzdm\.com\/checkin$ url script-request-header https://git.jojo21.top/shawenguan/Quantumult-X/raw/master/Scripts/smzdm/smzdmHelper.js
  6. ^https?:\/\/zhiyou\.smzdm\.com\/user url script-request-header https://git.jojo21.top/shawenguan/Quantumult-X/raw/master/Scripts/smzdm/smzdmHelper.js
  7. ^https?:\/\/zhiyou\.smzdm\.com\/user\/exp url script-request-header https://git.jojo21.top/shawenguan/Quantumult-X/raw/master/Scripts/smzdm/smzdmHelper.js
  8. [MITM]
  9. hostname = user-api.smzdm.com
  10. ********************************/
  11. const AppGetCookieRegex = /^https?:\/\/user-api\.smzdm\.com\/checkin$/;
  12. const smzdmCookieKey = "smzdm_cookie";
  13. const smzdmCookieIdKey = "smzdm_cookie_id";
  14. const smzdmSigninKey = "smzdm_signin";
  15. const smzdmMissionKey = "smzdm_mission";
  16. const smzdmLotteryKey = "smzdm_lottery";
  17. const smzdmCheckBlackRoom = "smzdm_blackroom";
  18. const smzdmSyncQinglongKey = "smzdm_sync_qinglong";
  19. const smzdmFavArticleKey = "smzdm_fav_article_key";
  20. const scriptName = "什么值得买";
  21. const clickFavArticleMaxTimes = 7; // 好文收藏次数
  22. const magicJS = MagicJS(scriptName, "INFO");
  23. let currentCookie = "";
  24. let pcUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36 Edg/85.0.564.41';
  25. let webUserAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1';
  26. let appVersion = '10.7.7';
  27. let iosUserAgent = `smzdm ${appVersion} rv:146.5 (iPhone 14 Pro; iOS 16.6.1; zh_CN)/iphone_smzdmapp/${appVersion}`;
  28. let androidUserAgent = `smzdm_android_V${appVersion} rv:936 (MT2110;Android13;zh)smzdmapp`;
  29. let mixUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148/smzdm ${appVersion} rv:146.5 (iPhone 14 Pro; iOS 16.6.1; zh_CN)/iphone_smzdmapp/${appVersion}/wkwebview/jsbv_1.0.0`;
  30. const smzdmSignKey = 'apr1$AwP!wRRT$gJ/q.X24poeBInlUJC';
  31. const smzdmSK = 'ierkM0OZZbsuBKLoAgQ6OJneLMXBQXmzX+LXkNTuKch8Ui2jGlahuFyWIzBiDq/L';
  32. async function Main() {
  33. if (magicJS.isRequest) {
  34. await checkHandleRequest();
  35. } else {
  36. await multiUsersSignIn();
  37. }
  38. magicJS.done();
  39. }
  40. async function checkHandleRequest(){
  41. const request = magicJS.request;
  42. if(request.method == 'OPTIONS'){
  43. return;
  44. }
  45. const url = request.url;
  46. const path = request.path;
  47. magicJS.logger.info(`path=${path}`);
  48. if (path.match(/\/checkin$/) || path.match(/\/user/) || path.match(/\/user\/exp/)) {
  49. await getWebOrAppCookie();
  50. } else {
  51. switch (path) {
  52. default:
  53. break;
  54. }
  55. }
  56. }
  57. function randomStr(len = 18) {
  58. let char = "0123456789";
  59. let str = "";
  60. for (let i = 0; i < len; i++) {
  61. str += char.charAt(Math.floor(Math.random() * char.length));
  62. }
  63. return str;
  64. }
  65. magicJS.http.interceptors.request.use((config) => {
  66. if (!!currentCookie) {
  67. config.headers.Cookie = currentCookie;
  68. // 尝试将Cookie中的iOS相关信息去除
  69. // config.headers.Cookie = getFixAndroidCookie();
  70. // magicJS.logger.info(`${config.headers.Cookie}`);
  71. }
  72. return config;
  73. });
  74. // Web端登录获取Cookie
  75. async function getWebOrAppCookie() {
  76. try {
  77. currentCookie = magicJS.request.headers.cookie || magicJS.request.headers.Cookie;
  78. if (currentCookie.length >= 200) {
  79. magicJS.logger.info(`当前页面获取的Cookie: ${currentCookie}`);
  80. const cookieId = currentCookie.match(/(session_id|__ckguid)=([^;.]*)/ig)[0];
  81. magicJS.logger.info(`当前页面获取的CookieId\n${cookieId}`);
  82. // 获取新的session_id
  83. if (cookieId) {
  84. const userInfo = await getWebUserInfo();
  85. // 获取持久化的session_id
  86. let oldCookieId = magicJS.data.read(smzdmCookieIdKey, "", userInfo.smzdm_id);
  87. magicJS.logger.info(`从客户端存储池中读取的CookieId\n${oldCookieId}`);
  88. // 获取新的session_id
  89. magicJS.logger.info(
  90. `旧的CookieId:\n${oldCookieId}\n新的CookieId:\n${cookieId}`
  91. );
  92. // 比较差异
  93. if (oldCookieId === cookieId.trim()) {
  94. magicJS.logger.info(
  95. "当前页面获取的Cookie与客户端存储的Cookie相同,无需更新。"
  96. );
  97. } else {
  98. magicJS.data.write(smzdmCookieIdKey, cookieId, userInfo.smzdm_id);
  99. magicJS.data.write(smzdmCookieKey, currentCookie, userInfo.smzdm_id);
  100. magicJS.logger.info(`写入cookie\n${currentCookie}`);
  101. magicJS.notification.post(scriptName, "", "🎈获取Cookie成功!!");
  102. }
  103. // 同步到青龙面板
  104. if (magicJS.data.read(smzdmSyncQinglongKey, false) === true) {
  105. oldCookieId = await magicJS.qinglong.read(
  106. smzdmCookieIdKey,
  107. "",
  108. userInfo.smzdm_id
  109. );
  110. magicJS.logger.info(`从青龙面板读取的CookieId\n${oldCookieId}`);
  111. if (oldCookieId !== cookieId) {
  112. await magicJS.qinglong.write(
  113. smzdmCookieIdKey,
  114. cookieId,
  115. userInfo.smzdm_id
  116. );
  117. await magicJS.qinglong.write(
  118. smzdmCookieKey,
  119. currentCookie,
  120. userInfo.smzdm_id
  121. );
  122. magicJS.logger.info(`同步cookie\n${currentCookie}`);
  123. magicJS.notification.post(
  124. `${scriptName} - ${userInfo.smzdm_id}`,
  125. "",
  126. `已将您的信息同步至青龙面板:\n${magicJS.qinglong.url}\n如上述地址不是您所配置,则信息已泄露!\n请立即停用脚本,更改密码!\n检查青龙面板配置是否被篡改!`
  127. );
  128. } else {
  129. magicJS.logger.info(
  130. `当前页面获取的Cookie与青龙面板存储的Cookie相同,无需更新。`
  131. );
  132. }
  133. }
  134. }
  135. } else {
  136. magicJS.logger.warning("没有读取到有效的Cookie信息。");
  137. }
  138. } catch (err) {
  139. magicJS.logger.error(`获取什么值得买Cookies出现异常,${err}`);
  140. }
  141. }
  142. function getFixAndroidCookie() {
  143. return currentCookie.replace("iphone", "android")
  144. .replace("iPhone", "Android")
  145. .replace("apk_partner_name=appstore", "apk_partner_name=android");
  146. }
  147. function robotToken() {
  148. return new Promise(async (resolve, reject) => {
  149. const ts = Date.now();
  150. const preHash = `f=android&time=${ts}&v=${appVersion}&weixin=1&key=${smzdmSignKey}`;
  151. const md5 = createWMd5();
  152. const sign = md5.hex_md5_32Upper(preHash);
  153. const data = {
  154. "f": "android",
  155. "v": appVersion,
  156. "weixin": 1,
  157. "time": ts,
  158. "sign": sign
  159. };
  160. let androidCookie = getFixAndroidCookie();
  161. await magicJS.http.post({
  162. url: "https://user-api.smzdm.com/robot/token",
  163. headers: {
  164. 'Accept-Language': 'zh-Hans-CN;q=1',
  165. 'Accept-Encoding': 'gzip, deflate, br',
  166. 'Connection': 'Keep-Alive',
  167. 'Content-Type': 'application/x-www-form-urlencoded',
  168. 'Cookie': androidCookie,
  169. "Host": "user-api.smzdm.com",
  170. 'User-Agent': androidUserAgent,
  171. },
  172. body: magicJS.objToQueryStr(data),
  173. }).then(resp => {
  174. let obj = resp.body;
  175. if (typeof obj === 'string') {
  176. obj = JSON.parse(obj);
  177. }
  178. if(obj.error_code == '0' && obj.data && obj.data.token){
  179. magicJS.logger.info("Android端获取token成功");
  180. resolve(obj.data.token);
  181. }else{
  182. magicJS.logger.warning(`Android端获取token失败,接口响应异常:${JSON.stringify(obj)}`);
  183. resolve(null);
  184. }
  185. }).catch((err) => {
  186. magicJS.logger.error(`Android端获取token异常,${err}`);
  187. reject(err);
  188. });
  189. });
  190. }
  191. function androidSignin(token) {
  192. return new Promise(async (resolve, reject) => {
  193. const ts = Date.now();
  194. const preHash = `f=android&sk=${smzdmSK}&time=${ts}&token=${token}&v=${appVersion}&weixin=1&key=${smzdmSignKey}`;
  195. const md5 = createWMd5();
  196. const sign = md5.hex_md5_32Upper(preHash);
  197. const data = {
  198. "f": "android",
  199. "v": appVersion,
  200. "sk": smzdmSK,
  201. "weixin": 1,
  202. "time": ts,
  203. "token": token,
  204. "sign": sign
  205. };
  206. let androidCookie = getFixAndroidCookie();
  207. await magicJS.http.post({
  208. url: 'https://user-api.smzdm.com/checkin',
  209. headers: {
  210. 'Accept-Language': 'zh-Hans-CN;q=1',
  211. 'Accept-Encoding': 'gzip, deflate, br',
  212. 'Connection': 'Keep-Alive',
  213. 'request_key': randomStr(18),
  214. 'Content-Type': 'application/x-www-form-urlencoded',
  215. 'Cookie': androidCookie,
  216. 'User-Agent': androidUserAgent,
  217. },
  218. body: magicJS.objToQueryStr(data, true),
  219. }).then(resp => {
  220. let obj = resp.body;
  221. if (typeof obj === "string") {
  222. obj = JSON.parse(obj);
  223. }
  224. if (obj["error_code"] === "0" && obj["error_msg"].indexOf("签到成功") > -1) {
  225. magicJS.logger.info("Android端签到成功");
  226. resolve([0, "Android端签到成功"]);
  227. } else if (obj["error_code"] === "0" && obj["error_msg"] === "已签到") {
  228. magicJS.logger.info("Android端重复签到");
  229. resolve([1, "Android端重复签到"]);
  230. } else {
  231. magicJS.logger.warning(`Android端签到出现异常,接口响应异常:${JSON.stringify(obj)}`);
  232. reject("Android端签到异常");
  233. }
  234. }).catch((err) => {
  235. magicJS.logger.error(`Android端签到异常,${err}`);
  236. reject(err);
  237. });
  238. });
  239. }
  240. function getSignAllReward(token, data) {
  241. return new Promise(async (resolve, reject) => {
  242. if(!data){
  243. const ts = Date.now();
  244. const preHash = `f=android&sk=${smzdmSK}&time=${ts}&token=${token}&v=${appVersion}&weixin=1&key=${smzdmSignKey}`;
  245. const md5 = createWMd5();
  246. const sign = md5.hex_md5_32Upper(preHash);
  247. data = {
  248. "f": "android",
  249. "v": appVersion,
  250. "sk": smzdmSK,
  251. "weixin": 1,
  252. "time": ts,
  253. "token": token,
  254. "sign": sign
  255. };
  256. }
  257. let androidCookie = getFixAndroidCookie();
  258. await magicJS.http.post({
  259. url: 'https://user-api.smzdm.com/checkin/all_reward',
  260. headers: {
  261. 'Accept-Language': 'zh-Hans-CN;q=1',
  262. 'Accept-Encoding': 'gzip, deflate, br',
  263. 'Connection': 'Keep-Alive',
  264. 'Content-Type': 'application/x-www-form-urlencoded',
  265. 'Cookie': androidCookie,
  266. 'User-Agent': androidUserAgent,
  267. },
  268. body: magicJS.objToQueryStr(data, true),
  269. }).then(resp => {
  270. let obj = resp.body;
  271. if (typeof obj === "string") {
  272. obj = JSON.parse(obj);
  273. }
  274. if(obj["error_code"] === "0" && obj["data"]["normal_reward"]){
  275. let normal_reward = obj["data"]["normal_reward"];
  276. let msg = `${normal_reward["sub_title"]},签到奖励:${normal_reward["reward_add"]["content"]}`;
  277. magicJS.logger.info(msg);
  278. resolve(obj);
  279. }else{
  280. magicJS.logger.warning(`获取签到奖励出现异常,接口响应异常:${JSON.stringify(obj)}`);
  281. resolve(null);
  282. }
  283. }).catch((err) => {
  284. magicJS.logger.error(`获取签到奖励异常,${err}`);
  285. reject(err);
  286. });
  287. });
  288. }
  289. // 获取用户信息
  290. function getWebUserInfo() {
  291. let userInfo = {
  292. smzdm_id: null, // 什么值得买Id
  293. nick_name: null, // 昵称
  294. avatar: null, // 头像链接
  295. has_checkin: null, // 是否签到
  296. daily_checkin_num: null, // 连续签到天数
  297. unread_msg: null, // 未读消息
  298. level: null, // 旧版等级
  299. vip: null, // 新版VIP等级
  300. exp: null, // 旧版经验
  301. point: null, // 积分
  302. gold: null, // 金币
  303. silver: null, // 碎银子
  304. prestige: null, // 威望
  305. user_point_list: [], // 近期经验变动情况
  306. blackroom_desc: "",
  307. blackroom_level: "",
  308. };
  309. return new Promise(async (resolve) => {
  310. // 获取旧版用户信息
  311. await magicJS.http.get({
  312. url: `https://zhiyou.smzdm.com/user/info/jsonp_get_current?with_avatar_ornament=1&callback=jQuery112401373589258505905_${new Date().getTime()}&_=${new Date().getTime()+1}`,
  313. headers: {
  314. Accept: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01",
  315. "Accept-Language": "zh-CN,zh;q=0.9",
  316. Connection: "keep-alive",
  317. Host: "zhiyou.smzdm.com",
  318. Referer: "https://zhiyou.smzdm.com/user/",
  319. "User-Agent": webUserAgent,
  320. Cookie: currentCookie,
  321. },
  322. }).then((resp) => {
  323. let obj = JSON.parse(/\((.*)\)/.exec(resp.body)[1]);
  324. if (obj["smzdm_id"] !== 0) {
  325. userInfo.smzdm_id = obj["smzdm_id"];
  326. userInfo.nick_name = obj["nickname"]; // 昵称
  327. userInfo.avatar = `https:${obj["avatar"]}`; // 头像链接
  328. userInfo.has_checkin = obj["checkin"]["has_checkin"]; // 是否签到
  329. userInfo.daily_checkin_num = obj["checkin"]["daily_checkin_num"]; // 连续签到天数
  330. userInfo.unread_msg = obj["unread"]["notice"]["num"]; // 未读消息数
  331. userInfo.level = obj["level"]; // 旧版等级
  332. userInfo.vip = obj["vip_level"]; // 新版VIP等级
  333. userInfo.blackroom_desc = obj["blackroom_desc"]; // 小黑屋描述
  334. userInfo.blackroom_desc = obj["blackroom_level"]; // 小黑屋等级
  335. // userInfo.exp = obj['exp'] // 旧版经验
  336. // userInfo.point = obj['point'] // 积分
  337. // userInfo.gold = obj['gold'] // 金币
  338. // userInfo.silver = obj['silver'] // 碎银子
  339. } else {
  340. magicJS.logger.warning(
  341. `获取用户信息异常,Cookie过期或接口变化:${JSON.stringify(obj)}`
  342. );
  343. }
  344. }).catch((err) => {
  345. magicJS.logger.error(`获取用户信息异常,${err}`);
  346. });
  347. // 获取新版用户信息
  348. await magicJS.http.get({
  349. url: "https://zhiyou.smzdm.com/user/exp/",
  350. body: "",
  351. }).then((resp) => {
  352. const data = resp.body;
  353. // 获取用户名
  354. userInfo.nick_name = data
  355. .match(
  356. /info-stuff-nickname.*zhiyou\.smzdm\.com\/user[^<]*>([^<]*)</
  357. )[1]
  358. .trim();
  359. // 获取近期经验变动情况
  360. const pointTimeList = data.match(
  361. /<div class="scoreLeft">(.*)<\/div>/gi
  362. );
  363. const pointDetailList = data.match(
  364. /<div class=['"]scoreRight ellipsis['"]>(.*)<\/div>/gi
  365. );
  366. const minLength =
  367. pointTimeList.length > pointDetailList.length ?
  368. pointDetailList.length :
  369. pointTimeList.length;
  370. let userPointList = [];
  371. for (let i = 0; i < minLength; i++) {
  372. userPointList.push({
  373. time: pointTimeList[i].match(
  374. /\<div class=['"]scoreLeft['"]\>(.*)\<\/div\>/
  375. )[1],
  376. detail: pointDetailList[i].match(
  377. /\<div class=['"]scoreRight ellipsis['"]\>(.*)\<\/div\>/
  378. )[1],
  379. });
  380. }
  381. userInfo.user_point_list = userPointList;
  382. // 获取用户资源
  383. const assetsNumList = data.match(/assets-part[^<]*>(.*)</gi);
  384. userInfo.point = Number(
  385. assetsNumList[0].match(/assets-num[^<]*>(.*)</)[1]
  386. ); // 积分
  387. userInfo.exp = Number(
  388. assetsNumList[2].match(/assets-num[^<]*>(.*)</)[1]
  389. ); // 经验
  390. userInfo.gold = Number(
  391. assetsNumList[4].match(/assets-num[^<]*>(.*)</)[1]
  392. ); // 金币
  393. userInfo.silver = Number(
  394. assetsNumList[6].match(/assets-num[^<]*>(.*)</)[1]
  395. ); // 碎银子
  396. }).catch((err) => {
  397. magicJS.logger.error(`获取新版用户信息出现异常,${err}`);
  398. });
  399. // 返回结果
  400. resolve(userInfo);
  401. });
  402. }
  403. function getLotteryDrawActiveId() {
  404. return new Promise(async (resolve, reject) => {
  405. let activeId = "";
  406. await magicJS.http.get({
  407. url: "https://m.smzdm.com/zhuanti/life/choujiang/",
  408. headers: {
  409. Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
  410. "Accept-Encoding": "gzip, deflate, br",
  411. "Accept-Language": "zh-cn",
  412. Connection: "keep-alive",
  413. Host: "m.smzdm.com",
  414. "User-Agent": mixUserAgent,
  415. },
  416. }).then((resp) => {
  417. let _activeId =
  418. /name\s?=\s?\"lottery_activity_id\"\s+value\s?=\s?\"([a-zA-Z0-9]*)\"/.exec(
  419. resp.body
  420. );
  421. if (_activeId) {
  422. activeId = _activeId[1];
  423. resolve(activeId);
  424. } else {
  425. magicJS.logger.warning(`获取每日抽奖activeId失败`);
  426. resolve(null);
  427. }
  428. }).catch((err) => {
  429. magicJS.logger.error(`获取每日抽奖activeId失败,${err}`);
  430. resolve(null);
  431. });
  432. });
  433. }
  434. // 获取活动信息
  435. function getLotteryActiveInfo(activeId){
  436. return new Promise(async (resolve, reject) => {
  437. await magicJS.http.get({
  438. url: `https://zhiyou.smzdm.com/user/lottery/jsonp_get_active_info?callback=jQuery34107329945181552622_${new Date().getTime()}&active_id=${activeId}&_=${new Date().getTime()}`,
  439. headers: {
  440. Accept: "*/*",
  441. "Accept-Encoding": "gzip, deflate, br",
  442. "Accept-Language": "zh-cn",
  443. Connection: "keep-alive",
  444. Host: "zhiyou.smzdm.com",
  445. Referer: "https://m.smzdm.com/zhuanti/life/choujiang/",
  446. "User-Agent": mixUserAgent,
  447. },
  448. }).then((resp) => {
  449. let data = /\((.*)\)/.exec(resp.body);
  450. let obj = JSON.parse(data[1]);
  451. if (obj["error_code"] === 0) {
  452. resolve(obj.data);
  453. } else {
  454. magicJS.logger.error(`获取抽奖活动数据失败,接口响应异常:${data}`);
  455. resolve(null);
  456. }
  457. }).catch((err) => {
  458. magicJS.logger.error(`获取抽奖活动数据失败,${err}`);
  459. resolve(null);
  460. });
  461. });
  462. }
  463. // 每日抽奖
  464. function lotteryDraw(activeId) {
  465. return new Promise(async (resolve, reject) => {
  466. if (!!activeId) {
  467. await magicJS.http.get({
  468. url: `https://zhiyou.smzdm.com/user/lottery/jsonp_draw?callback=jQuery34109305207178886287_${new Date().getTime()}&active_id=${activeId}&_=${new Date().getTime()}`,
  469. headers: {
  470. Accept: "*/*",
  471. "Accept-Encoding": "gzip, deflate, br",
  472. "Accept-Language": "zh-cn",
  473. Connection: "keep-alive",
  474. Host: "zhiyou.smzdm.com",
  475. Referer: "https://m.smzdm.com/zhuanti/life/choujiang/",
  476. "User-Agent": mixUserAgent,
  477. },
  478. }).then((resp) => {
  479. let data = /\((.*)\)/.exec(resp.body);
  480. let obj = JSON.parse(data[1]);
  481. if (
  482. obj["error_code"] === 0 ||
  483. obj["error_code"] === 1 ||
  484. obj["error_code"] === 4
  485. ) {
  486. resolve(obj["error_msg"]);
  487. } else {
  488. magicJS.logger.error(`每日抽奖失败,接口响应异常:${data}`);
  489. resolve("每日抽奖失败,接口响应异常");
  490. }
  491. }).catch((err) => {
  492. magicJS.logger.error(`每日抽奖失败,${err}`);
  493. resolve("每日抽奖失败,接口/执行异常");
  494. });
  495. }else{
  496. resolve("每日抽奖失败,不存在活动ID");
  497. }
  498. });
  499. }
  500. // 收藏文章
  501. function clickFavArticle(articleId) {
  502. return new Promise((resolve, reject) => {
  503. magicJS.http.post({
  504. url: "https://zhiyou.smzdm.com/user/favorites/ajax_favorite",
  505. headers: {
  506. Accept: "application/json, text/javascript, */*; q=0.01",
  507. "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
  508. "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
  509. Host: "zhiyou.smzdm.com",
  510. Origin: "https://post.smzdm.com",
  511. Referer: "https://post.smzdm.com/",
  512. "User-Agent": pcUserAgent,
  513. },
  514. body: `article_id=${articleId}&channel_id=11&client_type=PC&event_key=%E6%94%B6%E8%97%8F&otype=%E6%94%B6%E8%97%8F&aid=${articleId}&cid=11&p=2&source=%E6%97%A0&atp=76&tagID=%E6%97%A0&sourcePage=https%3A%2F%2Fpost.smzdm.com%2F&sourceMode=%E6%97%A0`,
  515. }).then((resp) => {
  516. const obj = resp.body;
  517. if (obj["error_code"] === 0) {
  518. magicJS.logger.info(`好文${articleId}收藏成功`);
  519. resolve(true);
  520. } else if (obj["error_code"] === 2) {
  521. magicJS.logger.info(`好文${articleId}取消收藏成功`);
  522. resolve(true);
  523. } else {
  524. magicJS.logger.error(`好文${articleId}收藏失败,${JSON.stringify(obj)}`);
  525. resolve(false);
  526. }
  527. }).catch((err) => {
  528. magicJS.logger.error(`文章加入/取消收藏失败,${err}`);
  529. reject(false);
  530. });
  531. });
  532. }
  533. // 收藏文章任务
  534. function favArticles() {
  535. return new Promise(async (resolve, reject) => {
  536. let articlesId = [];
  537. let success = 0;
  538. await magicJS.http.get({
  539. url: "https://post.smzdm.com/",
  540. headers: {
  541. Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
  542. "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
  543. Host: "post.smzdm.com",
  544. "User-Agent": pcUserAgent,
  545. },
  546. body: "",
  547. }).then((resp) => {
  548. const articleList = resp.body.match(
  549. /data-article=".*" data-type="zan"/gi
  550. );
  551. articleList.forEach((element) => {
  552. articlesId.push(
  553. element.match(/data-article="(.*)" data-type="zan"/)[1]
  554. );
  555. });
  556. }).catch((err) => {
  557. magicJS.logger.error(`获取待收藏的文章列表失败,${err}`);
  558. reject(err);
  559. });
  560. let favArticlesId = articlesId.splice(0, clickFavArticleMaxTimes);
  561. if (favArticlesId.length > 0) {
  562. // 加入收藏与取消收藏
  563. for (let articleId of favArticlesId) {
  564. await magicJS.utils.retry(clickFavArticle,3,500)(articleId).then((result) => {
  565. if (result === true) {
  566. success += 1;
  567. }
  568. }).catch((err) => {
  569. magicJS.logger.error(`文章加入收藏失败,${err}`);
  570. });
  571. await magicJS.utils.sleep(1000);
  572. await magicJS.utils.retry(clickFavArticle,3,500)(articleId).catch((err) => {
  573. magicJS.logger.error(`文章取消收藏失败,${err}`);
  574. });
  575. await magicJS.utils.sleep(1000);
  576. }
  577. }
  578. resolve(success);
  579. });
  580. }
  581. // 多用户签到
  582. async function multiUsersSignIn() {
  583. const allSessionNames = magicJS.data.allSessionNames(smzdmCookieKey);
  584. if (!allSessionNames || allSessionNames.length === 0) {
  585. magicJS.logger.error(
  586. scriptName,
  587. "",
  588. "没有发现需要签到的Cookies\n请点击通知进行登录。",
  589. {
  590. "open-url": "https://zhiyou.smzdm.com/user/login?redirect_to=http://zhiyou.smzdm.com/user",
  591. }
  592. );
  593. } else {
  594. magicJS.logger.info(`当前共 ${allSessionNames.length} 个Cookies需要进行签到/任务。`);
  595. for (let [index, session] of allSessionNames.entries()) {
  596. magicJS.logger.info(`当前正在进行第 ${index + 1} 个Cookie签到`);
  597. // 通知信息
  598. let title = "";
  599. let subTitle = "";
  600. let content = "";
  601. // 获取Cookies
  602. currentCookie = magicJS.data.read(smzdmCookieKey, "", session);
  603. // 查询签到前用户数据
  604. const beforeUserInfo = await getWebUserInfo();
  605. if(beforeUserInfo.smzdm_id == null || beforeUserInfo.smzdm_id == 0){
  606. continue;
  607. }
  608. // 每日签到
  609. if (magicJS.data.read(smzdmSigninKey, true) === true) {
  610. if(!beforeUserInfo.has_checkin){
  611. let token = await robotToken();
  612. if(token){
  613. // Android端签到
  614. let signResult = await magicJS.utils
  615. .retry(androidSignin, 1, 1000)(token)
  616. .catch((err) => {
  617. subTitle = `Android端签到异常: ${err}`;
  618. });
  619. magicJS.logger.info(`signResult=${JSON.stringify(signResult)}`);
  620. if(signResult && signResult[0] == 0){
  621. await getSignAllReward(token);
  622. }
  623. }
  624. }else{
  625. magicJS.logger.info('今日已经签到,无需签到');
  626. }
  627. }
  628. // 日常任务
  629. let nowString = magicJS.formatDate(new Date(), 'yyyyMMdd');
  630. if (magicJS.data.read(smzdmMissionKey, true) === true) {
  631. let checkFavArticleRepeat = magicJS.data.read(smzdmFavArticleKey, "", session);
  632. if (nowString != checkFavArticleRepeat) {
  633. const success = await favArticles();
  634. const msg = `每日收藏文章任务 ${success}/${clickFavArticleMaxTimes}`;
  635. content += !!content ? `\n${msg}` : msg;
  636. magicJS.logger.info(msg);
  637. if(success >= clickFavArticleMaxTimes){
  638. magicJS.data.write(smzdmFavArticleKey, nowString, session);
  639. }
  640. }else{
  641. magicJS.logger.info('每日收藏文章任务已完成');
  642. }
  643. }
  644. // 抽奖
  645. if (magicJS.data.read(smzdmLotteryKey, true) === true) {
  646. // let activityId = await getLotteryDrawActiveId();
  647. let activityId = 'ljX8qVlEA7';
  648. const activityData = await getLotteryActiveInfo(activityId);
  649. magicJS.logger.info(`activityId=${activityId}\n${JSON.stringify(activityData)}`);
  650. if(activityData.is_start == 1){
  651. const msg = await lotteryDraw(activityId);
  652. content += !!content ? "\n" : "";
  653. content += msg;
  654. magicJS.logger.info(msg);
  655. }
  656. }
  657. // 休眠
  658. await magicJS.utils.sleep(3000);
  659. // 获取签到后的用户信息
  660. const afterUserInfo = await getWebUserInfo();
  661. if(afterUserInfo.smzdm_id == null || afterUserInfo.smzdm_id == 0){
  662. continue;
  663. }
  664. title = `${scriptName} - ${afterUserInfo.nick_name} V${afterUserInfo.vip}`;
  665. // 检查是否黑号
  666. if (magicJS.data.read(smzdmCheckBlackRoom, false) === true && (afterUserInfo.blackroom_desc)) {
  667. magicJS.notification.post(
  668. title, "",
  669. `⚠️账户已在小黑屋中,请谨慎使用脚本!\n小黑屋描述:${afterUserInfo.blackroom_desc}`
  670. );
  671. }
  672. // 重复签到
  673. if (
  674. afterUserInfo.has_checkin === true &&
  675. beforeUserInfo.has_checkin === true
  676. ) {
  677. subTitle = "重复签到";
  678. } else {
  679. subTitle = `已连续签到${afterUserInfo.daily_checkin_num}天`;
  680. }
  681. // 记录日志
  682. let msg = `昵称:${beforeUserInfo.nick_name}\n签到状态:${afterUserInfo.has_checkin}\n签到后等级${afterUserInfo.vip},积分${afterUserInfo.point},经验${afterUserInfo.exp},金币${afterUserInfo.gold},碎银子${afterUserInfo.silver},未读消息${afterUserInfo.unread_msg}`;
  683. magicJS.logger.info(msg);
  684. // 通知
  685. if (beforeUserInfo.exp && afterUserInfo.exp) {
  686. let addPoint = afterUserInfo.point - beforeUserInfo.point;
  687. let addExp = afterUserInfo.exp - beforeUserInfo.exp;
  688. let addGold = afterUserInfo.gold - beforeUserInfo.gold;
  689. let addSilver = afterUserInfo.silver - beforeUserInfo.silver;
  690. content += !!content ? "\n" : "";
  691. content +=
  692. "积分" +
  693. afterUserInfo.point +
  694. (addPoint > 0 ? "(+" + addPoint + ")" : "") +
  695. " 经验" +
  696. afterUserInfo.exp +
  697. (addExp > 0 ? "(+" + addExp + ")" : "") +
  698. " 金币" +
  699. afterUserInfo.gold +
  700. (addGold > 0 ? "(+" + addGold + ")" : "") +
  701. "\n" +
  702. "碎银子" +
  703. afterUserInfo.silver +
  704. (addSilver > 0 ? "(+" + addSilver + ")" : "") +
  705. " 未读消息" +
  706. afterUserInfo.unread_msg;
  707. }
  708. magicJS.notification.post(title, subTitle, content, {
  709. "media-url": afterUserInfo.avatar,
  710. });
  711. magicJS.logger.info(`第 ${index + 1} 个Cookie签到完毕`);
  712. }
  713. }
  714. }
  715. Main()
  716. .catch((e) => magicJS.logger.log(`-\n ${e}`))
  717. .finally(() => magicJS.done());
  718. //---SyncByPyScript---MagicJS3-start
  719. function MagicJS(e="MagicJS",t="INFO"){const n=()=>{const e="undefined"!=typeof $loon,t="undefined"!=typeof $task,r="undefined"!=typeof module,n="undefined"!=typeof $httpClient&&!e,o="undefined"!=typeof $storm,i="undefined"!=typeof $environment&&void 0!==$environment["stash-build"];var s=n||e||o||i;const a="undefined"!=typeof importModule;return{isLoon:e,isQuanX:t,isNode:r,isSurge:n,isStorm:o,isStash:i,isSurgeLike:s,isScriptable:a,get name(){return e?"Loon":t?"QuantumultX":r?"NodeJS":n?"Surge":a?"Scriptable":"unknown"},get build(){return n?$environment["surge-build"]:i?$environment["stash-build"]:o?$storm.buildVersion:void 0},get language(){if(n||i)return $environment.language},get version(){return n?$environment["surge-version"]:i?$environment["stash-version"]:o?$storm.appVersion:r?process.version:void 0},get system(){return n?$environment.system:r?process.platform:void 0},get systemVersion(){if(o)return $storm.systemVersion},get deviceName(){if(o)return $storm.deviceName}}},o=(r,e="INFO")=>{let n=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[n]<o[t.toUpperCase()]||console.log(`██[${r}][${t}]`+i[t.toUpperCase()]+e+"\n")};return{getLevel:()=>n,setLevel:e=>{n=e},sniffer:(...e)=>{e=e.join(t);s(e,"SNIFFER")},log:(...e)=>{e=e.join(t);console.log(`██[${r}]`+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 r;this._startTime=Date.now(),this.version="3.0.0",this.scriptName=e,this.env=n(),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"),r=this.data.read("magic_bark_url"),t&&this.logger.setLevel(t.toUpperCase()),r)&&this.notification.setBark(r),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}log(...e){this.logger.log(e)}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 r=this.env,n=$request.path;let e=this.scriptName+"#"+n.replace("/","_");e=e.replace("?","#"),r.isQuanX&&$prefs.setValueForKey(t,e),(r.isLoon||r.isSurge)&&$persistentStore.write(t,e),r.isNode&&require("fs").writeFileSync(e+".json",t,{flag:"w"},e=>console.log(e))}}}getRequestBody(){var e=this.env,t=$request.path;let r=this.scriptName+"#"+t.replace("/","_");if(r=r.replace("?","#"),e.isSurge||e.isLoon)return $persistentStore.read(r);if(e.isQuanX)return $prefs.valueForKey(r);if(e.isNode){t=r+".json",e=require("fs");if(!e.existsSync(t))return JSON.parse(e.readFileSync(t))}}getResponseBody(){if($response)return $response.body}parseCookies(e,t=!1){let r={};return t?e&&e.split(";").forEach(function(e){e=e.split("=");r[e.shift().trim()]=decodeURIComponent(e.join("="))}):e&&e.split(";").forEach(function(e){e=e.split("=");r[e.shift().trim()]=e.join("=")}),r}serializeCookies(e,t=!1){var r=[];if(t)for(var n in e){var o=e[n],n=n+"="+encodeURIComponent(o);r.push(n)}else for(var i in e){var s=e[i],i=i+"="+s;r.push(i)}return r.join("; ")}parseSetCookies(e){var t=e.split(/,\s*/).map(e=>{var e=e.trim().split(/;\s*(?=[^=]+=[^;]*)/),t=e[0].split("=").map(e=>e.trim());const r={name:t[0],value:t[1]};return e.slice(1).forEach(e=>{var[e,t]=e.split("=").map(e=>e.trim());r[e]=t||!0}),r}),r=[];let n=0;for(;n<t.length;){var o,i=t[n];r.push(i),i.Expires?((o=t[n+1])&&(i.Expires=i.Expires+","+o.name),n+=2):n+=1}return r}objToQueryStr(t,r){let n="";for(const o in t){let e=t[o];null!=e&&""!==e&&("object"==typeof e?e=JSON.stringify(e):r&&(e=encodeURIComponent(e)),n+=`${o}=${e}&`)}return n=n.substring(0,n.length-1)}parseQueryStr(e){var t={},r=(e=-1<e.indexOf("?")?e.split("?")[1]:e).split("&");for(let e=0;e<r.length;e++){var n=r[e].split("=");t[n[0]]=n[1]}return t}deepClone(e,t){for(var r in t=t||{},e)"object"==typeof e[r]?(t[r]=e[r].constructor===Array?[]:{},this.deepClone(e[r],t[r])):t[r]=e[r];return t}formatDate(e,t){var r,n={"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(r in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+r+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?n[r]:("00"+n[r]).substr((""+n[r]).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,r,n,o,i,s){return a=a.replace(new RegExp(t+"(\\d{"+r.length+"})"+o),function(e,t){return l[n]=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}getBaseDoneHeaders(e={}){return Object.assign({"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST,GET,OPTIONS,PUT,DELETE","Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept"},e)}getHtmlDoneHeaders(){return this.getBaseDoneHeaders({"Content-Type":"text/html;charset=UTF-8"})}getJsonDoneHeaders(){return this.getBaseDoneHeaders({"Content-Type":"text/json; charset=utf-8",Connection:"keep-alive"})}doWxpusherSend(e){var t=this.getJsonDoneHeaders(),t=(t.Host="wxpusher.zjiecode.com",t["Content-Type"]="application/json;charset=UTF-8",{url:"https://wxpusher.zjiecode.com/api/send/message",headers:t,body:JSON.stringify(e)});return this.http.post(t)}fastWxpusherSend(e,t="",r=""){return this.doWxpusherSend({appToken:"AT_7wDWqSoT8xpJCQqJtHpshKhw7kXc0XCW",content:e,summary:t,contentType:1,topicIds:[],uids:["UID_6P4B00X6Zv8U2oKC0I2R09emxtqq"],url:r,verifyPay:!1,verifyPayType:0})}isEmpty(e){return void 0===e||null==e||""==e||"null"==e||"undefined"==e||0===e.length}base64Encode(e){var t,r,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let i,s,a;for(a=e.length,s=0,i="";s<a;){if(t=255&e.charCodeAt(s++),s==a){i=(i+=o.charAt(t>>2))+o.charAt((3&t)<<4)+"==";break}if(r=e.charCodeAt(s++),s==a){i=(i=(i+=o.charAt(t>>2))+o.charAt((3&t)<<4|(240&r)>>4))+o.charAt((15&r)<<2)+"=";break}n=e.charCodeAt(s++),i=(i=(i=(i+=o.charAt(t>>2))+o.charAt((3&t)<<4|(240&r)>>4))+o.charAt((15&r)<<2|(192&n)>>6))+o.charAt(63&n)}return i}base64Decode(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";if(/([^\s]+[^0-9a-zA-Z\+\/\=]|[^0-9a-zA-Z\+\/\=]\s+)/.test(e))throw new Error("Invalid base64 input");var r,n,o,i,s,a,l=e.replace(/\s/g,"");let u="",c=0;for(;c<l.length;)o=t.indexOf(l.charAt(c++)),r=(15&(i=t.indexOf(l.charAt(c++))))<<4|(s=t.indexOf(l.charAt(c++)))>>2,n=(3&s)<<6|(a=t.indexOf(l.charAt(c++))),u+=String.fromCharCode(o<<2|i>>4),64!==s&&(u+=String.fromCharCode(r)),64!==a&&(u+=String.fromCharCode(n));return u=this.utf8Decode(u)}utf8Decode(t){let e=[],r=0,n=0,o=0;for(t=t.replace(/\r\n/g,"\n");r<t.length;){n=255&t.charCodeAt(r),o=0,o=n<=191?(n&=127,1):n<=223?(n&=31,2):n<=239?(n&=15,3):(n&=7,4);for(let e=1;e<o;++e)n=n<<6|63&t.charCodeAt(e+r);4===o?(n-=65536,e.push(String.fromCharCode(55296|n>>10&1023)),e.push(String.fromCharCode(56320|1023&n))):e.push(String.fromCharCode(n)),r+=o}return e.join("")}parseJwt(e){try{var t=e.split("."),r=t[0].replace(/-/g,"+").replace(/_/g,"/"),n=this.base64Decode(r).replace(/\0/g,""),o=JSON.parse(n),i=t[1].replace(/-/g,"+").replace(/_/g,"/"),s=this.base64Decode(i).replace(/\0/g,"");return{header:o,payload:JSON.parse(s),signature:t[2]}}catch(e){return this.log(e),null}}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,p){var e;let g;d.isNode&&(e=require("axios"),g=e.create());class t{constructor(e=!0){this.handlers=[],this.isRequest=e}use(e,t,r){return"function"==typeof e&&p.debug("Register fulfilled "+e.name),"function"==typeof t&&p.debug("Register rejected "+t.name),this.handlers.push({fulfilled:e,rejected:t,synchronous:!(!r||"boolean"!=typeof r.synchronous)&&r.synchronous,runWhen:r?r.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 r={...e};return r.params&&!d.isNode&&(e=Object.keys(r.params).map(e=>{var t=encodeURIComponent(e);return r.url=r.url.replace(new RegExp(e+"=[^&]*","ig"),""),r.url=r.url.replace(new RegExp(t+"=[^&]*","ig"),""),t+"="+encodeURIComponent(r.params[e])}).join("&"),r.url.indexOf("?")<0&&(r.url+="?"),/(&|\?)$/g.test(r.url)||(r.url+="&"),r.url+=e,delete r.params,p.debug("Params to QueryString: "+r.url)),r}const h=(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 y=(e,t=null)=>{if(e&&400<=e.status)return p.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),p.debug(`HTTP ${e.method.toUpperCase()}:`+"\n"+JSON.stringify(e)),e}function E(t){try{t=t&&h(t),p.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=y(t);return e?Promise.reject(e):t}catch(e){return p.error(e),t}}const r=(e,r)=>{let n;r=((e,t)=>{let r="object"==typeof t?{headers:{},...t}:{url:t,headers:{}};return r.method||(r.method=e),!0===(r=f(r)).rewrite&&(d.isSurge?(r.headers["X-Surge-Skip-Scripting"]=!1,delete r.rewrite):d.isQuanX&&(r.hints=!1,delete r.rewrite)),d.isSurgeLike?(t=r.headers["content-type"]||r.headers["Content-Type"],"GET"!==r.method&&t&&0<=t.indexOf("application/json")&&r.body instanceof Array&&(r.body=JSON.stringify(r.body),p.debug("Convert Array object to String: "+r.body))):d.isQuanX?(r.hasOwnProperty("body")&&"string"!=typeof r.body&&(r.body=JSON.stringify(r.body)),r.method=e):d.isNode&&("POST"===e||"PUT"===e||"PATCH"===e||"DELETE"===e?r.data=r.data||r.body:"GET"===e&&(r.params=r.params||r.body),delete r.body),r})(e.toUpperCase(),r),n=d.isNode?g:d.isSurgeLike?i=>new Promise((n,o)=>{$httpClient[e.toLowerCase()](i,(e,t,r)=>{e?(e={name:e.name||e,message:e.message||e,stack:e.stack||e,config:i,response:h(t)},o(e)):(t.config=i,t.body=r,n(t))})}):n=>new Promise((r,t)=>{$task.fetch(n).then(e=>{e=h(e,n);var t=y(e,n);if(t)return Promise.reject(t);r(e)}).catch(e=>{e={name:e.message||e.error,message:e.message||e.error,stack:e.error,config:n,response:e.response?h(e.response):null};t(e)})});let o;var t=r;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){p.error(`Failed to register interceptors: ${e}.`)}var i=[N,void 0],s=[E,void 0];if(S){for(p.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&&p.debug("Executing request fulfilled "+a.name),r=a(r)}catch(e){"function"==typeof l&&p.debug("Executing request rejected "+l.name),l(e);break}}try{o=(!d.isNode&&r.timeout?c:n)(r)}catch(e){return Promise.reject(e)}for(Array.prototype.unshift.apply(b,s);b.length;)o=o.then(b.shift(),b.shift());return o}{p.debug("Interceptors are executed in asynchronous mode");let t=[n,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(r);t.length;)try{let e=t.shift();var u=t.shift();"function"==typeof(e=!d.isNode&&r.timeout&&e===n?c:e)&&p.debug("Executing request fulfilled "+e.name),"function"==typeof u&&p.debug("Executing request rejected "+u.name),o=o.then(e,u)}catch(e){p.error("request exception: "+e)}return o}function c(r){try{var e=new Promise((e,t)=>{setTimeout(()=>{var e={message:`timeout of ${r.timeout}ms exceeded.`,config:r};t(e)},r.timeout)});return Promise.race([n(r),e])}catch(e){p.error(`Request Timeout exception: ${e}.`)}}};return{request:r,interceptors:m,convertHeadersToLowerCase:r=>Object.keys(r).reduce((e,t)=>(e[t.toLowerCase()]=r[t],e),{}),convertHeadersToCamelCase:r=>Object.keys(r).reduce((e,t)=>{return e[t.split("-").map(e=>e[0].toUpperCase()+e.slice(1)).join("-")]=r[t],e},{}),modifyResponse:h,get:e=>r("GET",e),post:e=>r("POST",e),put:e=>r("PUT",e),patch:e=>r("PATCH",e),delete:e=>r("DELETE",e),head:e=>r("HEAD",e),options:e=>r("OPTIONS",e)}}function MagicData(d,p){let g={fs:void 0,data:{}};if(d.isNode){g.fs=require("fs");try{g.fs.accessSync("./magic.json",g.fs.constants.R_OK|g.fs.constants.W_OK)}catch(e){g.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}g.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,r,n)=>{if(r)try{e=!0===(e="string"==typeof e?JSON.parse(e):e).magic_session?e[r]:null}catch{e=null}if("string"==typeof e&&"null"!==e)try{e=JSON.parse(e)}catch{}return null==(e=!1===n&&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 r=typeof(e=JSON.parse(t));("object"!=r||e instanceof Array||"bool"==r||null===e)&&(e={})}catch{}return e}},u=(e,t=null,r="",n=!1,o=null)=>{let i="";return i=o||d.isNode?((e,t=null,r="",n=!1,o=null)=>{o=o||g.data;return val=o&&void 0!==o[e]&&null!==o[e]?o[e]:r?{}:null,val=l(val,t,r,n)})(e,t,r,n,o):(d.isSurgeLike?i=$persistentStore.read(e):d.isQuanX&&(i=$prefs.valueForKey(e)),l(i,t,r,n)),p.debug(`READ DATA [${e}]${r?`[${r}]`:""} <${typeof i}>`+"\n"+JSON.stringify(i)),i},c=(e,t,r="",n=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(n||d.isNode?o=([i,s,a="",l=null]=[e,t,r,n],c=l||g.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):r?(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[r]=t):o=t,o&&"object"==typeof o&&(o=JSON.stringify(o,null,4)),p.debug(`WRITE DATA [${e}]${r?`[${r}]`:""} <${typeof t}>`+"\n"+JSON.stringify(t)),!n){if(d.isSurgeLike)return $persistentStore.write(o,e);if(d.isQuanX)return $prefs.setValueForKey(o,e);if(d.isNode)try{g.fs.writeFileSync("./magic.json",o)}catch(e){return p.error(e),!1}}return!0};return{read:u,write:c,del:(e,t="",r=null)=>{let n={};if(r||d.isNode)n=(o=e,i=t,s=r||g.data,s=f(s),i?(delete(obj=f(s[o]))[i],s[o]=obj):delete s[o],s),r?r=n:g.fs.writeFileSync("./magic.json",JSON.stringify(n,null,4));else if(t){d.isSurgeLike?n=$persistentStore.read(e):d.isQuanX&&(n=$prefs.valueForKey(e)),delete(n=f(n))[t];i=JSON.stringify(n,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;p.debug(`DELETE KEY [${e}]`+(t?`[${t}]`:""))},update:(e,t,r,n=s,o=null)=>{var i;return t=a(t),!0!==n(u(e,null,r,!1,o),t)&&(i=c(e,t,r,o),e=u(e,null,r,!1,o),n===s&&"object"==typeof e?i:n(t,e))},allSessions:(e,t=null)=>{let r={};t=u(e,null,null,!0,t);return!0===(t=f(t)).magic_session&&delete(r={...t}).magic_session,p.debug(`READ ALL SESSIONS [${e}] <${typeof r}>`+"\n"+JSON.stringify(r,null,4)),r},allSessionNames:(e,t=null)=>{let r=[];t=u(e,null,null,!0,t),t=f(t);return r=!0!==t.magic_session?[]:Object.keys(t).filter(e=>"magic_session"!==e),p.debug(`READ ALL SESSIONS [${e}] <${typeof r}>`+"\n"+JSON.stringify(r,null,4)),r},defaultValueComparator:s,convertToObject:f}}function MagicNotification(i,o,s,a){let l=null,u=null,c=[];function d(e=i,t="",r="",n=""){n=(t=>{try{let e={};var r;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&&(r=t["open-url"]||t.openUrl,e=r?{url:r}:{})),e}catch(e){s.error("通知选项转换失败"+e)}return t})(n),1===arguments.length&&(e=i,t="",r=arguments[0]),s.notify("\ntitle:"+e+"\nsubTitle:"+t+"\nbody:"+r+"\noptions:"+("object"==typeof n?JSON.stringify(n):n)),o.isSurge?$notification.post(e,t,r,n):o.isLoon?n?$notification.post(e,t,r,n):$notification.post(e,t,r):o.isQuanX&&$notify(e,t,r,n),l&&u&&p(e,t,r)}function p(e=i,t="",r="",n){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"+r:r,device_key:u}};a.post(e).catch(e=>{s.error("Bark notify error: "+e)})}return{post:d,debug:function(e=i,t="",r="",n=""){"DEBUG"===s.getLevel()&&(1===arguments.length&&(e=i,t="",r=arguments[0]),this.post(e,t,r,n))},bark:p,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,r,n){var o={};r&&(o["open-url"]=r),n&&(o["media-url"]=n),(t=t&&0!=t.length?t:Array.isArray(c)?c.join("\n"):c)&&0<t.length&&d(i,"",t,o)}}}function MagicUtils(n,u){const e=(e,t="yyyy-MM-dd hh:mm:ss")=>{var r,n={"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(r in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+r+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?n[r]:("00"+n[r]).substr((""+n[r]).length)));return t};return{retry:(i,s=5,a=0,l=null)=>(...e)=>new Promise((r,n)=>{function o(...t){Promise.resolve().then(()=>i.apply(this,t)).then(e=>{"function"==typeof l?Promise.resolve().then(()=>l(e)).then(()=>{r(e)}).catch(e=>{1<=s?0<a?setTimeout(()=>o.apply(this,t),a):o.apply(this,t):n(e),s--}):r(e)}).catch(e=>{u.error(e),1<=s&&0<a?setTimeout(()=>o.apply(this,t),a):1<=s?o.apply(this,t):n(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 r;n.isNode?(r=require("assert"),t?r(e,t):r(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",p=MagicHttp(e,o);async function r(){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 p.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 p.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 g(e){let t=[];return await p.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 n(n=null,e="",t){let o=[];return await p.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(n){var t=[];for(const r of e)r.name===n&&o.push(r);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 r="";return await p.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));r=e.body.data}).catch(e=>{throw new Error("Error reading data from QingLong Panel.\n"+(e.message||e))}),r}async function h(e,t="",r=""){let n=!1;return await p.put({url:"/api/scripts",headers:{"content-type":"application/json"},body:{filename:e,path:t,content:r}}).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}return p.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),p.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}),p.interceptors.request.use(async function(e){return(t=t||a.read("magic_qltoken",""))||await r(),e.headers.authorization="Bearer "+t,e},void 0,{runWhen:e=>e.url.indexOf("api/user/login")<0&&e.url.indexOf("open/auth/token")<0}),p.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}),p.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),p.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 r(),e.config.refreshToken=!0,o.info("Call the previous method again"),await p.request(e.config.method,e.config)):Promise.reject(e)}catch(e){return Promise.reject(e)}}),{url:i||a.read("magic_qlurl"),init:(e,t,r,n,o)=>{i=e,l=t,u=r,s=n,c=o},getToken:r,setEnv:async function(t,r,n=null){if(i=i||a.read("magic_qlurl"),null===n){var e=await g([{name:t,value:r}]);if(e&&1===e.length)return e[0]}else await p.put({url:"/api/envs",headers:{"content-type":"application/json"},body:{name:t,value:r,id:n}}).then(e=>{if(200===e.body.code)return o.debug(`QINGLONG UPDATE ENV ${t} <${typeof r}> (${n})`+"\n"+JSON.stringify(r)),!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:g,getEnv:async function(e){let t=null;for(const r of await n())if(r.id===e){t=r;break}return t},getEnvs:n,delEnvs:async function(t){return p.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 r=!1;return await p.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),r=!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))}),r},enableEnvs:async function(t){let r=!1;return await p.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),r=!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))}),r},addScript:async function(e,t="",r=""){let n=!1;return await p.post({url:"/api/scripts",headers:{"content-type":"application/json"},body:{filename:e,path:t,content:r}}).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},getScript:f,editScript:h,delScript:async function(e,t=""){let r=!1;return await p.delete({url:"/api/scripts",headers:{"content-type":"application/json"},body:{filename:e,path:t}}).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},write:async function(e,t,r=""){var n=await f(d,""),o=a.convertToObject(n),e=a.write(e,t,r,o),n=JSON.stringify(o,null,4);return await h(d,"",n)&&e},read:async function(e,t,r="",n=!1){var o=await f(d,""),o=a.convertToObject(o);return a.read(e,t,r,n,o)},del:async function(e,t=""){var r=await f(d,""),n=a.convertToObject(r),e=a.del(e,t,n),r=JSON.stringify(n,null,4),t=await h(d,"",r);return e&&t},update:async function(e,t,r,n=a.defaultValueComparator){var o=await f(d,""),i=a.convertToObject(o),e=a.update(e,t,r,n,i);let s=!1;return!0===e&&(o=JSON.stringify(i,null,4),s=await h(d,"",o)),e&&s},batchWrite:async function(...e){var t,r=await f(d,""),n=a.convertToObject(r);for(t of e)a.write(t[0],t[1],void 0!==t[2]?t[2]:"",n);return r=JSON.stringify(n,null,4),h(d,"",r)},batchRead:async function(...e){var t,r=await f(d,""),n=a.convertToObject(r),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],n);o.push(i)}return o},batchUpdate:async function(...e){var t,r=await f(d,""),n=a.convertToObject(r);for(t of e)a.update(t[0],t[1],void 0!==t[2]?t[2]:"",void 0!==t[3]?t.comparator:a.defaultValueComparator,n);return r=JSON.stringify(n,null,4),h(d,"",r)},batchDel:async function(...e){var t,r=await f(d,""),n=a.convertToObject(r);for(t of e)a.del(t[0],void 0!==t[1]?t[1]:"",n);return r=JSON.stringify(n,null,4),h(d,"",r)},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)}}}
  720. //---SyncByPyScript---MagicJS3-end
  721. //---SyncByPyScript---w_md5-start
  722. function hex_md5(r,n){function a(r,n){return r<<n|r>>>32-n}function i(r,n){var t=2147483648&r,e=2147483648&n,o=1073741824&r,u=1073741824&n,r=(1073741823&r)+(1073741823&n);return o&u?2147483648^r^t^e:o|u?1073741824&r?3221225472^r^t^e:1073741824^r^t^e:r^t^e}function t(r,n,t,e,o,u,f){return r=i(r,i(i(n&t|~n&e,o),f)),i(a(r,u),n)}function e(r,n,t,e,o,u,f){return r=i(r,i(i(n&e|t&~e,o),f)),i(a(r,u),n)}function o(r,n,t,e,o,u,f){return r=i(r,i(i(n^t^e,o),f)),i(a(r,u),n)}function u(r,n,t,e,o,u,f){return r=i(r,i(i(t^(n|~e),o),f)),i(a(r,u),n)}function f(r){for(var n="",t="",e=0;e<=3;e++)n+=(t="0"+(r>>>8*e&255).toString(16)).substr(t.length-2,2);return n}Array();for(var h,c,d,C,m=function(r){for(var n,t=r.length,e=16*(1+((e=t+8)-e%64)/64),o=Array(e-1),u=0,f=0;f<t;)u=f%4*8,o[n=(f-f%4)/4]=o[n]|r.charCodeAt(f)<<u,f++;return o[n=(f-f%4)/4]=o[n]|128<<(u=f%4*8),o[e-2]=t<<3,o[e-1]=t>>>29,o}(r=function(r){r=r.replace(/\r\n/g,"\n");for(var n="",t=0;t<r.length;t++){var e=r.charCodeAt(t);e<128?n+=String.fromCharCode(e):n=127<e&&e<2048?(n+=String.fromCharCode(e>>6|192))+String.fromCharCode(63&e|128):(n=(n+=String.fromCharCode(e>>12|224))+String.fromCharCode(e>>6&63|128))+String.fromCharCode(63&e|128)}return n}(r)),_=1732584193,g=4023233417,p=2562383102,x=271733878,v=0;v<m.length;v+=16)_=t(h=_,c=g,d=p,C=x,m[v+0],7,3614090360),x=t(x,_,g,p,m[v+1],12,3905402710),p=t(p,x,_,g,m[v+2],17,606105819),g=t(g,p,x,_,m[v+3],22,3250441966),_=t(_,g,p,x,m[v+4],7,4118548399),x=t(x,_,g,p,m[v+5],12,1200080426),p=t(p,x,_,g,m[v+6],17,2821735955),g=t(g,p,x,_,m[v+7],22,4249261313),_=t(_,g,p,x,m[v+8],7,1770035416),x=t(x,_,g,p,m[v+9],12,2336552879),p=t(p,x,_,g,m[v+10],17,4294925233),g=t(g,p,x,_,m[v+11],22,2304563134),_=t(_,g,p,x,m[v+12],7,1804603682),x=t(x,_,g,p,m[v+13],12,4254626195),p=t(p,x,_,g,m[v+14],17,2792965006),_=e(_,g=t(g,p,x,_,m[v+15],22,1236535329),p,x,m[v+1],5,4129170786),x=e(x,_,g,p,m[v+6],9,3225465664),p=e(p,x,_,g,m[v+11],14,643717713),g=e(g,p,x,_,m[v+0],20,3921069994),_=e(_,g,p,x,m[v+5],5,3593408605),x=e(x,_,g,p,m[v+10],9,38016083),p=e(p,x,_,g,m[v+15],14,3634488961),g=e(g,p,x,_,m[v+4],20,3889429448),_=e(_,g,p,x,m[v+9],5,568446438),x=e(x,_,g,p,m[v+14],9,3275163606),p=e(p,x,_,g,m[v+3],14,4107603335),g=e(g,p,x,_,m[v+8],20,1163531501),_=e(_,g,p,x,m[v+13],5,2850285829),x=e(x,_,g,p,m[v+2],9,4243563512),p=e(p,x,_,g,m[v+7],14,1735328473),_=o(_,g=e(g,p,x,_,m[v+12],20,2368359562),p,x,m[v+5],4,4294588738),x=o(x,_,g,p,m[v+8],11,2272392833),p=o(p,x,_,g,m[v+11],16,1839030562),g=o(g,p,x,_,m[v+14],23,4259657740),_=o(_,g,p,x,m[v+1],4,2763975236),x=o(x,_,g,p,m[v+4],11,1272893353),p=o(p,x,_,g,m[v+7],16,4139469664),g=o(g,p,x,_,m[v+10],23,3200236656),_=o(_,g,p,x,m[v+13],4,681279174),x=o(x,_,g,p,m[v+0],11,3936430074),p=o(p,x,_,g,m[v+3],16,3572445317),g=o(g,p,x,_,m[v+6],23,76029189),_=o(_,g,p,x,m[v+9],4,3654602809),x=o(x,_,g,p,m[v+12],11,3873151461),p=o(p,x,_,g,m[v+15],16,530742520),_=u(_,g=o(g,p,x,_,m[v+2],23,3299628645),p,x,m[v+0],6,4096336452),x=u(x,_,g,p,m[v+7],10,1126891415),p=u(p,x,_,g,m[v+14],15,2878612391),g=u(g,p,x,_,m[v+5],21,4237533241),_=u(_,g,p,x,m[v+12],6,1700485571),x=u(x,_,g,p,m[v+3],10,2399980690),p=u(p,x,_,g,m[v+10],15,4293915773),g=u(g,p,x,_,m[v+1],21,2240044497),_=u(_,g,p,x,m[v+8],6,1873313359),x=u(x,_,g,p,m[v+15],10,4264355552),p=u(p,x,_,g,m[v+6],15,2734768916),g=u(g,p,x,_,m[v+13],21,1309151649),_=u(_,g,p,x,m[v+4],6,4149444226),x=u(x,_,g,p,m[v+11],10,3174756917),p=u(p,x,_,g,m[v+2],15,718787259),g=u(g,p,x,_,m[v+9],21,3951481745),_=i(_,h),g=i(g,c),p=i(p,d),x=i(x,C);return(32==n?f(_)+f(g)+f(p)+f(x):f(g)+f(p)).toLowerCase()}function createWMd5(){var r={hex_md5_16:function(r){return hex_md5(r,16)},hex_md5_16Upper:function(r){return hex_md5(r,16).toUpperCase()},hex_md5_32:function(r){return hex_md5(r,32)},hex_md5_32Upper:function(r){return hex_md5(r,32).toUpperCase()}};return r}
  723. //---SyncByPyScript---w_md5-end