manmanbuyHelper.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /******************************
  2. > 慢慢买
  3. *******************************
  4. [rewrite_local]
  5. ^https?:\/\/apph5\.manmanbuy\.com\/taolijin\/(login.aspx|logserver.aspx) url script-request-body https://git.jojo21.top/shawenguan/Quantumult-X/raw/master/Scripts/manmanbuy/manmanbuyHelper.js
  6. [MITM]
  7. hostname=apph5.manmanbuy.com
  8. ********************************/
  9. const SCRIPT_NAME = '慢慢买';
  10. const GET_COOKIE_REGEX = /https:?\/\/apph5\.manmanbuy\.com\/taolijin\/logserver.aspx/;
  11. const LOGIN_REGEX = /https?:\/\/apph5\.manmanbuy\.com\/taolijin\/login.aspx/
  12. const CHECKIN_COOKIE_KEY = 'manmanbuy_checkin_cookie';
  13. const LOGIN_BODY_KEY = 'manmanbuy_login_body';
  14. const USERTOKEN_KEY = 'manmanbuy_usertoken';
  15. const USERNAME_KEY = 'manmanbuy_username';
  16. const DEVICEID_KEY = 'manmanbuy_deviceid';
  17. let magicJS = MagicJS(SCRIPT_NAME, "INFO");
  18. magicJS.unifiedPushUrl = magicJS.read('manmanbuy_unified_push_url') || magicJS.read('magicjs_unified_push_url');
  19. let userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 - mmbWebBrowse - ios ';
  20. let login_options = {
  21. url: 'https://apph5.manmanbuy.com/taolijin/login.aspx',
  22. headers: {
  23. 'content-type':'application/x-www-form-urlencoded; charset=UTF-8',
  24. 'accept': 'application/json, text/javascript, */*; q=0.01',
  25. 'sec-fetch-site':'same-origin',
  26. 'accept-language':'zh-CN,zh-Hans;q=0.9',
  27. 'accept-encoding':'gzip, deflate, br',
  28. 'sec-fetch-mode':'cors',
  29. 'origin':'https://apph5.manmanbuy.com',
  30. 'content-length':'66',
  31. 'user-agent': userAgent,
  32. 'referer':'https://apph5.manmanbuy.com/renwu/index.aspx?m_from=my_daka',
  33. 'sec-fetch-dest':'empty',
  34. 'cookie': '',
  35. 'savedata': 'false'
  36. },
  37. body: ''
  38. }
  39. let checkin_options = {
  40. url: 'https://apph5.manmanbuy.com/renwu/index.aspx?m_from=my_daka',
  41. headers: {
  42. 'accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  43. 'sec-fetch-site':'none',
  44. 'accept-encoding':'gzip, deflate, br',
  45. 'sec-fetch-mode':'navigate',
  46. 'user-agent':userAgent,
  47. 'accept-language':'zh-CN,zh-Hans;q=0.9',
  48. 'sec-fetch-dest':'document'
  49. },
  50. body: ''
  51. }
  52. async function Main() {
  53. if (magicJS.isRequest) {
  54. handleRequest();
  55. magicJS.done();
  56. } else {
  57. let loginResult = await login();
  58. if (loginResult) {
  59. let userInfo = await getUserInfo();
  60. if(userInfo){
  61. if(!userInfo.isTodayCheckin){
  62. await checkIn();
  63. }else{
  64. magicJS.notify(`今日已经签到,已连续签到${userInfo.continueCheckinCount}天`);
  65. }
  66. }else{
  67. magicJS.notify('❌获取用户信息失败');
  68. }
  69. }
  70. magicJS.done();
  71. }
  72. }
  73. function handleRequest(){
  74. const request = magicJS.request;
  75. if (LOGIN_REGEX.test(request.url) && request.headers.hasOwnProperty('savedata') == false) {
  76. let hisBody = magicJS.read(LOGIN_BODY_KEY, 'default');
  77. if (hisBody != request.body) {
  78. magicJS.write(LOGIN_BODY_KEY, request.body, 'default');
  79. let reqParams = magicJS.parseQueryStr(request.body);
  80. let username = reqParams.u_name;
  81. let usertoken = reqParams.u_token;
  82. if(username && usertoken){
  83. magicJS.write(USERTOKEN_KEY, usertoken, 'default');
  84. magicJS.write(USERNAME_KEY, username, 'default');
  85. }
  86. magicJS.log('获取登录Body成功。')
  87. magicJS.notify('🎈获取登录Body成功!!');
  88. } else {
  89. magicJS.log('登录Body没有变化,无需更新。')
  90. }
  91. } else if (GET_COOKIE_REGEX.test(request.url)) {
  92. try {
  93. let hisCookie = magicJS.read(CHECKIN_COOKIE_KEY, 'default');
  94. let cookie = request.headers['Cookie'];
  95. let reqParams = magicJS.parseQueryStr(request.body);
  96. let devicedId = reqParams.deviceid;
  97. let username = reqParams.username;
  98. let hisDevicedId = magicJS.read(DEVICEID_KEY, 'default');
  99. let hisUsername = magicJS.read(USERNAME_KEY, 'default');
  100. if (hisCookie != cookie || devicedId != hisDevicedId || hisUsername != username) {
  101. magicJS.write(DEVICEID_KEY, devicedId, 'default');
  102. magicJS.write(USERNAME_KEY, username, 'default');
  103. magicJS.write(CHECKIN_COOKIE_KEY, cookie, 'default');
  104. magicJS.log('获取签到Cookie和Body成功。')
  105. magicJS.notify('🎈获取签到Cookie和Body成功!!');
  106. } else {
  107. magicJS.logInfo(`Cookie没有变化,无需更新。`);
  108. }
  109. } catch (err) {
  110. magicJS.log(`获取签到Cookie和Body失败,执行异常${err}`);
  111. magicJS.notify('❌获取签到Cookie和Body失败,执行异常!!');
  112. }
  113. }
  114. }
  115. function login(){
  116. return new Promise((resolve) => {
  117. let cookie = magicJS.read(CHECKIN_COOKIE_KEY, 'default');
  118. let body = magicJS.read(LOGIN_BODY_KEY, 'default');
  119. let username = magicJS.read(USERNAME_KEY, 'default');
  120. let usertoken = magicJS.read(USERTOKEN_KEY, 'default');
  121. // magicJS.log(`cookie=${cookie}`);
  122. // magicJS.log(`username=${username}`);
  123. // magicJS.log(`usertoken=${usertoken}`);
  124. if (!!cookie && !!username && !!usertoken) {
  125. body = `action=newtokenlogin&u_name=${username}&u_token=${usertoken}`;
  126. login_options.headers['cookie'] = cookie;
  127. login_options.body = body;
  128. magicJS.post(login_options, (err, resp, data) => {
  129. if (err) {
  130. magicJS.log(`登录失败,http请求异常:${err}`);
  131. resolve(false);
  132. } else {
  133. try {
  134. let obj = JSON.parse(data);
  135. if (obj['code'] == 1) {
  136. magicJS.log('登录成功');
  137. resolve(true);
  138. } else {
  139. magicJS.log(`登录失败,接口响应不合法:${data}`);
  140. magicJS.notify('❌登录失败,接口响应不合法。');
  141. resolve(false);
  142. }
  143. } catch (err) {
  144. magicJS.log(`登录失败,执行异常:${err},接口响应:${data}`);
  145. magicJS.notify('❌登录失败,执行异常。');
  146. resolve(false);
  147. }
  148. }
  149. });
  150. } else {
  151. magicJS.notify('❌登录失败,请先获取登录Cookie和Body!!');
  152. resolve(false);
  153. }
  154. });
  155. }
  156. function getUserInfo(){
  157. return new Promise((resolve) => {
  158. let cookie = magicJS.read(CHECKIN_COOKIE_KEY, 'default');
  159. let devicedId = magicJS.read(DEVICEID_KEY, 'default');
  160. let username = magicJS.read(USERNAME_KEY, 'default');
  161. let body = `action=get_user_info&username=${username}&c_devid=${devicedId}&isAjaxInvoke=true`;
  162. if (!!cookie && !!body) {
  163. checkin_options.referer = 'https://apph5.manmanbuy.com/renwu/index.aspx?m_from=my_daka';
  164. checkin_options.url = 'https://apph5.manmanbuy.com/renwu/index.aspx';
  165. checkin_options.headers['cookie'] = cookie;
  166. checkin_options.body = body;
  167. magicJS.post(checkin_options, (err, resp, data) => {
  168. let retData = null;
  169. if (err) {
  170. magicJS.log(`获取用户信息失败,http请求异常:${err}`);
  171. } else {
  172. try {
  173. magicJS.log(data);
  174. let obj = JSON.parse(data);
  175. if (obj['code'] == 1) {
  176. retData = obj.data;
  177. }
  178. } catch (err) {
  179. magicJS.log(`获取用户信息失败,执行异常:${err},接口响应:${data}`);
  180. }
  181. }
  182. resolve(retData);
  183. })
  184. } else {
  185. resolve();
  186. }
  187. });
  188. }
  189. function checkIn(){
  190. return new Promise((resolve) => {
  191. let cookie = magicJS.read(CHECKIN_COOKIE_KEY, 'default');
  192. let devicedId = magicJS.read(DEVICEID_KEY, 'default');
  193. let username = magicJS.read(USERNAME_KEY, 'default');
  194. let body = `action=checkin&username=${username}&c_devid=${devicedId}&isAjaxInvoke=true`;
  195. if (!!cookie && !!body) {
  196. checkin_options.url = 'https://apph5.manmanbuy.com/renwu/index.aspx?m_from=my_daka';
  197. checkin_options.headers['cookie'] = cookie;
  198. checkin_options.body = body;
  199. magicJS.post(checkin_options, (err, resp, data) => {
  200. if (err) {
  201. magicJS.log(`签到失败,http请求异常:${err}`);
  202. } else {
  203. try {
  204. let obj = JSON.parse(data);
  205. if (obj['code'] == 1) {
  206. magicJS.log(`签到成功,获得积分${obj['data']['jifen']},已连续签到${obj['data']['zt']}天!!`);
  207. magicJS.notify(`🎉签到成功\n🎁获得积分${obj['data']['jifen']},已连续签到${obj['data']['zt']}天!!`)
  208. } else if (obj['code'] == 0) {
  209. magicJS.log(`签到失败,可能是重复签到,接口响应:${data}`);
  210. magicJS.notify('❌签到失败,可能是重复签到!!');
  211. } else {
  212. magicJS.log(`签到失败,接口响应不合法:${data}`);
  213. magicJS.notify('❌签到失败,接口响应不合法!!');
  214. }
  215. } catch (err) {
  216. magicJS.log(`签到失败,执行异常:${err},接口响应:${data}`);
  217. magicJS.notify('❌签到失败,执行异常!!');
  218. }
  219. }
  220. resolve();
  221. })
  222. } else {
  223. magicJS.notify('❌签到失败,请先获取签到Cookie!!');
  224. resolve();
  225. }
  226. });
  227. }
  228. Main()
  229. .catch((e) => magicJS.log(`-\n ${e}`))
  230. .finally(() => magicJS.done());
  231. //---SyncByPyScript---MagicJS2-start
  232. function MagicJS(e="MagicJS",t="INFO"){return new class{constructor(){if(this._startTime=Date.now(),this.version="2.2.3.7",this.scriptName=e,this.logLevels={DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1},this.isLoon="undefined"!=typeof $loon,this.isQuanX="undefined"!=typeof $task,this.isJSBox="undefined"!=typeof $drive,this.isNode="undefined"!=typeof module&&!this.isJSBox,this.isSurge="undefined"!=typeof $httpClient&&!this.isLoon,this.node={request:void 0,fs:void 0,data:{}},this.iOSUserAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1",this.pcUserAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36 Edg/84.0.522.59",this._logLevel="INFO",this.logLevel=t,this._barkUrl="",this._barkKey="",this.isNode){this.node.fs=require("fs"),this.node.request=require("request");try{this.node.fs.accessSync("./magic.json",this.node.fs.constants.R_OK|this.node.fs.constants.W_OK)}catch(e){this.node.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}this.node.data=require("./magic.json")}else this.isJSBox&&($file.exists("drive://MagicJS")||$file.mkdir("drive://MagicJS"),$file.exists("drive://MagicJS/magic.json")||$file.write({data:$data({string:"{}"}),path:"drive://MagicJS/magic.json"}));this.log(e+", 开始执行!")}set barkUrl(e){try{var t=e.replace(/\/+$/g,"");this._barkUrl=/^https?:\/\/([^/]*)/.exec(t)[0]+"/push",this._barkKey=/\/([^\/]+)\/?$/.exec(t)[1]}catch(e){this.logDebug("Bark config error.")}}set logLevel(e){var t=this.read("magicjs_loglevel");this._logLevel=t||e.toUpperCase()}get logLevel(){return this._logLevel}get isRequest(){return"undefined"!=typeof $request&&"undefined"==typeof $response}get isResponse(){return"undefined"!=typeof $response}get isDebug(){return"DEBUG"===this.logLevel}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}get platform(){return this.isSurge?"Surge":this.isQuanX?"Quantumult X":this.isLoon?"Loon":this.isJSBox?"JSBox":this.isNode?"Node.js":"Unknown"}read(t,s=""){let i="";this.isSurge||this.isLoon?i=$persistentStore.read(t):this.isQuanX?i=$prefs.valueForKey(t):this.isNode?i=this.node.data:this.isJSBox&&(i=$file.read("drive://MagicJS/magic.json").string);try{this.isNode&&(i=i[t]),this.isJSBox&&(i=JSON.parse(i)[t]),s&&(i=(i="string"==typeof i?JSON.parse(i):i)&&"object"==typeof i?i[s]:null)}catch(e){this.logError(e),i=s?{}:null,this.del(t)}void 0===i&&(i=null);try{var e;i&&"string"==typeof i&&"object"==typeof(e=JSON.parse(i))&&e&&(i=e)}catch(e){}return this.logDebug(`READ DATA [${t}]${s?`[${s}]`:""}(${typeof i})`+"\n"+JSON.stringify(i)),i}write(t,e,s=""){let i=s?{}:"";if(s&&(this.isSurge||this.isLoon)?i=$persistentStore.read(t):s&&this.isQuanX?i=$prefs.valueForKey(t):this.isNode?i=this.node.data:this.isJSBox&&(i=JSON.parse($file.read("drive://MagicJS/magic.json").string)),s){try{i="object"==typeof(i="string"==typeof i?JSON.parse(i):i)&&i?i:{}}catch(e){this.logError(e),this.del(t),i={}}this.isJSBox||this.isNode?(i[t]&&"object"==typeof i[t]||(i[t]={}),i[t].hasOwnProperty(s)||(i[t][s]=null),void 0===e?delete i[t][s]:i[t][s]=e):void 0===e?delete i[s]:i[s]=e}else this.isNode||this.isJSBox?void 0===e?delete i[t]:i[t]=e:i=void 0===e?null:e;"object"==typeof i&&(i=JSON.stringify(i)),this.isSurge||this.isLoon?$persistentStore.write(i,t):this.isQuanX?$prefs.setValueForKey(i,t):this.isNode?this.node.fs.writeFileSync("./magic.json",i):this.isJSBox&&$file.write({data:$data({string:i}),path:"drive://MagicJS/magic.json"}),this.logDebug(`WRITE DATA [${t}]${s?`[${s}]`:""}(${typeof e})`+"\n"+JSON.stringify(e))}del(e,t=""){this.logDebug(`DELETE KEY [${e}]`+(t?`[${t}]`:"")),this.write(e,null,t)}notify(e=this.scriptName,t="",s="",i=""){i=(e=>{let t={};return"string"==typeof e?0<e.length&&(this.isLoon?t={openUrl:e}:this.isQuanX?t={"open-url":e}:this.isSurge&&(t={url:e})):"object"==typeof e&&(this.isLoon?(t.openUrl=e["open-url"]||"",t.mediaUrl=e["media-url"]||""):this.isQuanX?t=e["open-url"]||e["media-url"]?e:{}:this.isSurge&&(e=e["open-url"]||e.openUrl,t=e?{url:e}:{})),t})(i),1==arguments.length&&(e=this.scriptName,t="",s=arguments[0]),this.logNotify("\ntitle:"+e+"\nsubTitle:"+t+"\nbody:"+s+"\noptions:"+("object"==typeof i?JSON.stringify(i):i)),this.isSurge?$notification.post(e,t,s,i):this.isLoon?i?$notification.post(e,t,s,i):$notification.post(e,t,s):this.isQuanX?$notify(e,t,s,i):this.isJSBox&&$push.schedule({title:e,body:t?t+"\n"+s:s}),this._barkUrl&&this._barkKey&&this.notifyBark(e,t,s)}notifyDebug(e=this.scriptName,t="",s="",i=""){"DEBUG"===this.logLevel&&(1==arguments.length&&(e=this.scriptName,t="",s=arguments[0]),this.notify(e,t,s,i))}notifyBark(e=this.scriptName,t="",s="",i){e={url:this._barkUrl,headers:{"Content-Type":"application/json; charset=utf-8"},body:{title:e,body:t?t+"\n"+s:s,device_key:this._barkKey}};this.post(e,e=>{})}log(e,t="INFO"){this.logLevels[this._logLevel]<this.logLevels[t.toUpperCase()]||console.log(`██[${this.scriptName}][${t}]`+e+"\n")}logDebug(e){this.log(e,"DEBUG")}logInfo(e){this.log(e,"INFO")}logNotify(e){this.log(e,"NOTIFY")}logWarning(e){this.log(e,"WARNING")}logError(e){this.log(e,"ERROR")}logRetry(e){this.log(e,"RETRY")}adapterHttpOptions(e,t){let s="object"==typeof e?Object.assign({},e):{url:e,headers:{}},i=(s.hasOwnProperty("header")&&!s.hasOwnProperty("headers")&&(s.headers=s.header,delete s.header),s.headers&&"object"==typeof s.headers&&(s.headers["User-Agent"]||s.headers["user-agent"])||(s.headers&&"object"==typeof s.headers||(s.headers={}),this.isNode?s.headers["User-Agent"]=this.pcUserAgent:s.headers["User-Agent"]=this.iOSUserAgent),!1);return(i="object"==typeof s.opts&&(!0===s.opts.hints||!0===s.opts["Skip-Scripting"])||"object"==typeof s.headers&&!0===s.headers["X-Surge-Skip-Scripting"]?!0:i)||(this.isSurge?s.headers["X-Surge-Skip-Scripting"]=!1:this.isLoon?s.headers["X-Requested-With"]="XMLHttpRequest":this.isQuanX&&("object"!=typeof s.opts&&(s.opts={}),s.opts.hints=!1)),this.isSurge&&!i||delete s.headers["X-Surge-Skip-Scripting"],!this.isQuanX&&s.hasOwnProperty("opts")&&delete s.opts,this.isQuanX&&s.hasOwnProperty("opts")&&delete s.opts["Skip-Scripting"],"GET"===t&&!this.isNode&&s.body&&(e=Object.keys(s.body).map(e=>void 0===s.body?"":encodeURIComponent(e)+"="+encodeURIComponent(s.body[e])).join("&"),s.url.indexOf("?")<0&&(s.url+="?"),s.url.lastIndexOf("&")+1!=s.url.length&&s.url.lastIndexOf("?")+1!=s.url.length&&(s.url+="&"),s.url+=e,delete s.body),this.isQuanX?(s.hasOwnProperty("body")&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body)),s.method=t):this.isNode?(delete s.headers["Accept-Encoding"],"object"==typeof s.body&&("GET"===t?(s.qs=s.body,delete s.body):"POST"===t&&(s.json=!0,s.body=s.body))):this.isJSBox&&(s.header=s.headers,delete s.headers),s}adapterHttpResponse(e){let t={body:e.body,headers:e.headers,json:()=>JSON.parse(t.body)};return e.hasOwnProperty("statusCode")&&e.statusCode&&(t.status=e.statusCode),t}get(e,i){e=this.adapterHttpOptions(e,"GET");this.logDebug("HTTP GET: "+JSON.stringify(e)),this.isSurge||this.isLoon?$httpClient.get(e,i):this.isQuanX?$task.fetch(e).then(e=>{e.status=e.statusCode,i(null,e,e.body)},e=>i(e.error,null,null)):this.isNode?this.node.request.get(e,(e,t,s)=>{t=this.adapterHttpResponse(t),i(e,t,s)}):this.isJSBox&&(e.handler=e=>{var t=e.error?JSON.stringify(e.error):void 0,s="object"==typeof e.data?JSON.stringify(e.data):e.data;i(t,e.response,s)},$http.get(e))}getPromise(e){return new Promise((s,i)=>{magicJS.get(e,(e,t)=>{e?i(e):s(t)})})}post(e,i){var t,e=this.adapterHttpOptions(e,"POST");this.logDebug("HTTP POST: "+JSON.stringify(e)),this.isSurge||this.isLoon?$httpClient.post(e,i):this.isQuanX?$task.fetch(e).then(e=>{e.status=e.statusCode,i(null,e,e.body)},e=>{i(e.error,null,null)}):this.isNode?((t=this.node.request.post(e,i)).status=t.statusCode,delete t.statusCode):this.isJSBox&&(e.handler=e=>{var t=e.error?JSON.stringify(e.error):void 0,s="object"==typeof e.data?JSON.stringify(e.data):e.data;i(t,e.response,s)},$http.post(e,{}))}costTime(){var e=this.scriptName+"执行完毕!",t=(this._endTime=(new Date).getTime(),this._endTime-this._startTime);this.log(e+`耗时【${t/1e3}】秒`)}done(e={}){this.costTime(),"undefined"!=typeof $done&&$done(e)}isToday(e){var t;return null!=e&&(t=new Date,"string"==typeof e&&(e=new Date(e)),t.getFullYear()==e.getFullYear())&&t.getMonth()==e.getMonth()&&t.getDay()==e.getDay()}isNumber(e){return"NaN"!==parseFloat(e).toString()}attempt(e,t=null){return e.then(e=>[null,e]).catch(e=>(this.logError(e),[e,t]))}retry(r,n=5,a=0,h=null){return(...e)=>new Promise((s,i)=>{function o(...t){Promise.resolve().then(()=>r.apply(this,t)).then(e=>{"function"==typeof h?Promise.resolve().then(()=>h(e)).then(()=>{s(e)}).catch(e=>{1<=n?0<a?setTimeout(()=>o.apply(this,t),a):o.apply(this,t):i(e),n--}):s(e)}).catch(e=>{this.logRetry(e),1<=n&&0<a?setTimeout(()=>o.apply(this,t),a):1<=n?o.apply(this,t):i(e),n--})}o.apply(this,e)})}formatTime(e,t="yyyy-MM-dd hh:mm:ss"){var s,i={"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(s in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),i)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[s]:("00"+i[s]).substr((""+i[s]).length)));return t}now(){return this.formatTime(new Date,"yyyy-MM-dd hh:mm:ss")}today(){return this.formatTime(new Date,"yyyy-MM-dd")}sleep(t){return new Promise(e=>setTimeout(e,t))}objToQueryStr(t,s){let i="";for(const o in t){let e=t[o];null!=e&&""!==e&&("object"==typeof e?e=JSON.stringify(e):s&&(e=encodeURIComponent(e)),i+=`${o}=${e}&`)}return i=i.substring(0,i.length-1)}parseQueryStr(e){var t={},s=(e=-1<e.indexOf("?")?e.split("?")[1]:e).split("&");for(let e=0;e<s.length;e++){var i=s[e].split("=");t[i[0]]=i[1]}return t}deepClone(e,t){for(var s in t=t||{},e)"object"==typeof e[s]?(t[s]=e[s].constructor===Array?[]:{},this.deepClone(e[s],t[s])):t[s]=e[s];return t}convertToObject(t){if("string"!=typeof t)return t instanceof Array||null==t||t!=t||"boolean"==typeof t?{}:t;{let e={};try{var s=typeof(e=JSON.parse(t));("object"!=s||e instanceof Array||"boolean"==s||null===e)&&(e={})}catch{}return e}}}(e)}
  233. //---SyncByPyScript---MagicJS2-end