Sub-Store外置流量查询脚本 该脚本基于Sub-Store, 可解决APP使用Sub-Store链接后, 没有流量通知的问题. 使用前需确认您的机场订阅是否支持流量信息. (注:节点名流量信息暂不支持) Sub-Store订阅管理器: https://github.com/Peng-YM/Sub-Store 最后更新: 2022.6.12 测试兼容: QuantumultX, Surge, Loon. 使用方法: 打开Sub-Store => 订阅 => 编辑 => 节点操作+ => 脚本操作 => 填入脚本链接或粘贴脚本 => 保存 您的APP更新Sub-Store订阅链接时,
(proxies, client)
| 16 | ******************************/ |
| 17 | |
| 18 | async function operator(proxies, client) { |
| 19 | if (['JSON', 'URI'].includes(client)) return proxies; |
| 20 | const $ = $substore; //OpenAPI in Sub-Store |
| 21 | const single = $.read('subs'); |
| 22 | const collection = $.read('collections'); |
| 23 | const subtag = decodeURIComponent($request.url.split(/download\/(collection\/|)(.*)/)[2]); |
| 24 | const group = []; |
| 25 | if ($request.url.includes('/collection/')) { //collection subscription. |
| 26 | const deployed = collection[subtag].process.filter((c) => c.type == 'Script Operator' && c.args.content.includes('/DataQuery.js')).length; |
| 27 | for (let i = 0; i < collection[subtag].subscriptions.length; i++) { |
| 28 | if (deployed) group.push({ |
| 29 | name: collection[subtag].subscriptions[i], url: single[collection[subtag].subscriptions[i]].url |
| 30 | }); |
| 31 | } |
| 32 | } else { //single subscription. |
| 33 | group.push({ name: single[subtag].name, url: single[subtag].url }) |
| 34 | } |
| 35 | await Promise.all( |
| 36 | group.map((c) => $.http.get(c.url) |
| 37 | .then((r) => { |
| 38 | const t = parseInfo(r); |
| 39 | $.notify( |
| 40 | `🔹 订阅昵称:「 ${c.name} 」`, |
| 41 | t.expire ? `🔹 过期时间:「 ${t.expire} 」` : ``, |
| 42 | `🔸 已用流量:「 ${t.used} GB 」\n🔸 剩余流量:「 ${t.free} GB 」` |
| 43 | ); |
| 44 | }) |
| 45 | .catch((e) => $.notify(`🔹 订阅昵称:「 ${c.name} 」`, ``, `🔺 查询失败:「 ${e.message || e} 」`)) |
| 46 | ) |
| 47 | ) |
| 48 | return proxies; |
| 49 | } |
| 50 | |
| 51 | function parseInfo(resp) { //reference to https://github.com/KOP-XIAO/QuantumultX/blob/master/Scripts/resource-parser.js |
| 52 | var sinfo = JSON.stringify(resp.headers || '').replace(/ /g, "").toLowerCase(); |