* 获取远程版本
(scriptUrl, timeout = 3 * 1000)
| 304 | * 获取远程版本 |
| 305 | */ |
| 306 | function getVersion(scriptUrl, timeout = 3 * 1000) { |
| 307 | return new Promise((resolve) => { |
| 308 | const options = { url: `https://fastly.jsdelivr.net/gh/${scriptUrl}` }; |
| 309 | $.get(options, (err, resp, data) => { |
| 310 | try { |
| 311 | const regex = /scriptVersionNow\s*=\s*(["'`])([\d.]+)\1/; |
| 312 | const match = data.match(regex); |
| 313 | const scriptVersionLatest = match ? match[2] : ""; |
| 314 | console.log(`\n====== 当前版本:${scriptVersionNow} 📌 最新版本:${scriptVersionLatest} ======`); |
| 315 | } catch (e) { |
| 316 | $.logErr(e, resp); |
| 317 | } |
| 318 | resolve(); |
| 319 | }, timeout); |
| 320 | }); |
| 321 | } |
| 322 | /** |
| 323 | * 获取远程通知 |
| 324 | */ |