| 358 | } |
| 359 | //==============================================获取远程版本================================================= |
| 360 | function getVersion(scriptUrl, timeout = 3 * 1000) { |
| 361 | return new Promise((resolve) => { |
| 362 | const options = { url: `https://fastly.jsdelivr.net/gh/${scriptUrl}` }; |
| 363 | $.get(options, (err, resp, data) => { |
| 364 | try { |
| 365 | const regex = /scriptVersionNow\s*=\s*(["'`])([\d.]+)\1/; |
| 366 | const match = data.match(regex); |
| 367 | const scriptVersionLatest = match ? match[2] : ""; |
| 368 | console.log(`\n====== 当前版本:${scriptVersionNow} 📌 最新版本:${scriptVersionLatest} ======`); |
| 369 | } catch (e) { |
| 370 | $.logErr(e, resp); |
| 371 | } |
| 372 | resolve(); |
| 373 | }, timeout); |
| 374 | }); |
| 375 | } |
| 376 | //=================================GOT=========================================================== |
| 377 | async function request(opt) { |
| 378 | const DEFAULT_RETRY = 3 //请求出错重试三次 |