Compare commits
12 Commits
eccba9325a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e3822fb25 | ||
|
|
a0fb927f78 | ||
|
|
3afc41ba1c | ||
|
|
a877f3a7a4 | ||
|
|
9d5e454c40 | ||
|
|
4777c8a6ea | ||
|
|
256888f56c | ||
|
|
9f8aaf1b05 | ||
|
|
569e04a263 | ||
|
|
471bc16d80 | ||
|
|
ac838303cd | ||
|
|
436e8415a2 |
200
README.md
200
README.md
@@ -1,77 +1,88 @@
|
|||||||
# GLM Coding 抢购助手 v4.0
|
# GLM Coding 抢购助手 v4.6(OpenClaw Mod)
|
||||||
|
|
||||||
智谱 GLM Coding Plan 限时抢购自动化脚本(Tampermonkey 油猴脚本)
|
智谱 GLM Coding Plan 限时抢购自动化脚本(Tampermonkey 油猴脚本)
|
||||||
|
基于 [qtaxm/glm-rush](https://github.com/qtaxm/glm-rush) v4.6 修改
|
||||||
|
|
||||||
|
## vs 原版的差异
|
||||||
|
|
||||||
|
本版本在原版基础上增加了以下改进:
|
||||||
|
|
||||||
|
| 修改 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| **A1 空单过滤** | check 返回金额为 0 视为空单,继续重试 |
|
||||||
|
| **A2 Vue 响应式保护** | patchSoldOut 跳过 `__ob__`/`__v_isVNode`/`__v_isRef` 防止崩溃 |
|
||||||
|
| **A3 提前触发** | 可配置提前 X 秒触发,补偿 RTT 网络延迟 |
|
||||||
|
| **A4 捡漏模式** | maxRetry 耗尽后自动降速(2路/3s间隔)等退票 |
|
||||||
|
| **A5 全局 soldOut 补丁** | 所有 fetch 响应的 JSON 中移除 isSoldOut/soldOut/isServerBusy/stock=0 |
|
||||||
|
| **B1 Promise.allSettled** | 并发取消不报 rejected,统一 settled 处理 |
|
||||||
|
| **B2 favicon.ico 时间同步** | 改用 favicon.ico HEAD 请求,采样 3 次取中位数 |
|
||||||
|
| **B3 预热策略** | 改用空 POST + favicon.ico,提前 5 分钟开始预热 |
|
||||||
|
| **B4 waitForBuyButton** | 按钮轮询最多 8 秒(每 200ms),支持 class/文本双策略 |
|
||||||
|
| **B5 stopAll abort** | 停止时主动 abort 所有进行中的 AbortController |
|
||||||
|
| **B6 getVueRoot** | Vue 2/3 兼容获取根实例辅助函数 |
|
||||||
|
| **B7 支付弹窗恢复重置** | 检测到支付弹窗时重置 recoveryAttempts |
|
||||||
|
| **C1 555 视为 EXPIRE** | code=555 系统繁忙加入立即重试列表,429 退避上限 8 秒 |
|
||||||
|
| **C2 连续售罄比例判断** | 60% 售罄即计数,非全量才计数 |
|
||||||
|
| **C3 rAF 精度提升** | 最后 1 秒切换 requestAnimationFrame,setInterval/rAF 互斥 |
|
||||||
|
| **C4 sessionStorage 版本校验** | 写入 `__v:1`,读取时校验版本,不一致则清除 |
|
||||||
|
| **C5 history 路由劫持** | pushState/replaceState 拦截,离开确认提示 |
|
||||||
|
| **C6 fakeXHR setProp** | try-catch + Object.defineProperty 双重保护属性赋值 |
|
||||||
|
| **D1 放票时间警告** | 面板显示「⚠️ 每次确认放票时间」提示 |
|
||||||
|
| **D2 dismissDialog Escape** | 弹窗关闭前优先发送 Escape 键盘事件 |
|
||||||
|
| **D3 getDelay 参数名** | 参数名从 `attempt` 改为 `round`(语义更准确) |
|
||||||
|
| **D4 VERSION 常量** | 统一 `const VERSION = '4.6'` 变量管理 |
|
||||||
|
|
||||||
## 功能特点
|
## 功能特点
|
||||||
|
|
||||||
- **并发重试** — 3 路并发请求,任一成功立即返回(比单线程快 3x)
|
- **极速并发引擎** — 双模式并发:极速模式 10 路 + 普通模式 5 路,任一成功立即取消其余
|
||||||
- **自适应间隔** — 前 10 次零延迟爆发 → 快速重试 → 随机间隔,带 ±30% 抖动
|
- **自适应间隔** — 前 20 次零延迟爆发 → 30ms 快速重试 → 100ms 随机间隔,带 ±30% 抖动
|
||||||
- **preview + check 双重校验** — 获取 bizId 后调用 check 确认有效,EXPIRE 立即重试
|
- **preview + check 双重校验** — 获取 bizId 后调用 check 确认有效,EXPIRE/空单 立即重试
|
||||||
- **4 层支付恢复** — 暴力清弹窗 → 缓存重点击 → 直接获取支付链接 → 兜底提醒
|
- **4 层支付恢复** — 暴力清弹窗 → 缓存重点击 → 直接获取支付链接 → 兜底提醒
|
||||||
- **反检测** — JSON.parse 定向拦截(不污染全局)、fetch/XHR toString 伪装、Shadow DOM 面板隔离
|
- **反检测** — 请求指纹随机化(X-Request-Id / X-Timestamp / Accept-Language)、JSON.parse 定向拦截、fetch/XHR toString 伪装、Shadow DOM 面板隔离
|
||||||
- **高精度定时** — requestAnimationFrame + performance.now,精度 ±2ms
|
- **高精度定时** — requestAnimationFrame + performance.now,精度 ±2ms,提前触发补偿 RTT
|
||||||
- **配置持久化** — localStorage 保存并发数/上限等配置,sessionStorage 保存捕获的请求
|
- **配置持久化** — localStorage 保存所有配置,sessionStorage 保存捕获的请求(带版本校验)
|
||||||
- **错误弹窗自动恢复** — MutationObserver 监控弹窗出现,自动关闭并重新触发购买
|
- **弹窗自动恢复** — MutationObserver 监控弹窗,自动关闭并重新触发,最多 3 次
|
||||||
- **TCP 预热** — 提前建立连接,减少首次请求延迟
|
- **捡漏模式** — 抢购失败后自动降速等待退票
|
||||||
|
- **离开保护** — 路由跳转时确认是否中断抢购
|
||||||
- **快捷键** — `Alt+S` 开始 / `Alt+X` 停止 / `Alt+H` 隐藏面板
|
- **快捷键** — `Alt+S` 开始 / `Alt+X` 停止 / `Alt+H` 隐藏面板
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
### 方式 1:从 GitHub Raw 安装(推荐)
|
### 方式 1:从 Gitea Raw 安装(推荐)
|
||||||
|
|
||||||
1. 安装 [Tampermonkey](https://www.tampermonkey.net/) 浏览器扩展
|
1. 安装 [Tampermonkey](https://www.tampermonkey.net/) 浏览器扩展
|
||||||
2. 点击安装:[glm-rush-v4.user.js](https://raw.githubusercontent.com/qtaxm/glm-rush/master/glm-rush-v4.user.js)
|
2. 点击安装:[glm-rush-v4.user.js](https://gitea.ephron.ren/OpenClaw/glm-rush/raw/branch/master/glm-rush-v4.user.js)
|
||||||
3. Tampermonkey 自动弹出安装页面,点击 **安装**
|
3. Tampermonkey 自动弹出安装页面,点击 **安装**
|
||||||
|
|
||||||
### 方式 2:手动安装
|
### 方式 2:从 GitHub Raw 安装(原版)
|
||||||
|
|
||||||
1. 复制 `glm-rush-v4.user.js` 的内容
|
1. 安装 [Tampermonkey](https://www.tampermonkey.net/) 浏览器扩展
|
||||||
2. 打开 Tampermonkey → 添加新脚本 → 粘贴 → 保存
|
2. 点击安装:[glm-rush-v4.user.js](https://raw.githubusercontent.com/qtaxm/glm-rush/master/glm-rush-v4.user.js)(原版)
|
||||||
|
|
||||||
## 使用方法
|
## 使用方法
|
||||||
|
|
||||||
1. 打开 [GLM Coding 页面](https://bigmodel.cn/glm-coding)
|
1. 打开 [GLM Coding 页面](https://bigmodel.cn/glm-coding)
|
||||||
2. 右上角出现 **GLM v4.0** 控制面板
|
2. 右上角出现控制面板
|
||||||
3. **手动点一次购买按钮** — 脚本捕获请求参数(面板显示"已捕获")
|
3. **手动点一次购买按钮** — 脚本捕获请求参数(面板显示"已捕获")
|
||||||
4. 选择触发方式:
|
4. 选择触发方式:
|
||||||
- **主动抢购**:立即开始并发重试
|
- **主动抢购**:立即开始并发重试
|
||||||
- **定时触发**:设定时间,到点自动开始
|
- **定时触发**:设定时间(默认 10:00:00),到点自动开始
|
||||||
- **预热**:提前建立 TCP 连接
|
|
||||||
5. 抢购成功后自动弹出支付页面
|
5. 抢购成功后自动弹出支付页面
|
||||||
|
|
||||||
## 控制面板
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────────────┐
|
|
||||||
│ GLM v4.0 [-] │
|
|
||||||
├─────────────────────────┤
|
|
||||||
│ ● 重试中... 45/500 │
|
|
||||||
│ 已捕获: POST .../preview│
|
|
||||||
│ │
|
|
||||||
│ [重试:45] [成功:0] [错误:3] │
|
|
||||||
│ │
|
|
||||||
│ 并发 [3] 上限 [500] │
|
|
||||||
│ 定时 [--:--] [设定] │
|
|
||||||
│ │
|
|
||||||
│ [▶ 主动抢购] [停止] [预热]│
|
|
||||||
│ │
|
|
||||||
│ 10:00:01 捕获 preview │
|
|
||||||
│ 10:00:01 #3 系统繁忙 │
|
|
||||||
│ 10:00:02 #15 售罄 │
|
|
||||||
│ 10:00:03 成功! bizId=xx │
|
|
||||||
└─────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
## 配置参数
|
## 配置参数
|
||||||
|
|
||||||
| 参数 | 默认值 | 说明 |
|
| 参数 | 默认值 | 说明 |
|
||||||
|------|--------|------|
|
|------|--------|------|
|
||||||
| 并发数 | 3 | 同时发起的请求数 |
|
| 并发路数 | 5 | 普通模式同时发起的请求数 |
|
||||||
| 最大重试 | 500 | 达到上限后停止 |
|
| 极速并发 | 10 | 前 5 秒的高并发路数 |
|
||||||
| 爆发次数 | 10 | 前 N 次零延迟 |
|
| 极速时长 | 5s | 高并发持续多久 |
|
||||||
| 快速间隔 | 50ms | 爆发后的重试间隔 |
|
| 最大重试 | 2000 | 达到上限后进入捡漏模式 |
|
||||||
| 慢速间隔 | 150ms | 后期重试间隔中值 |
|
| 爆发次数 | 20 | 前 N 次零延迟 |
|
||||||
|
| 快速间隔 | 30ms | 爆发后的重试间隔 |
|
||||||
|
| 慢速间隔 | 100ms | 后期重试间隔中值 |
|
||||||
| 抖动 | ±30% | 间隔随机化幅度 |
|
| 抖动 | ±30% | 间隔随机化幅度 |
|
||||||
|
| 抢购时间 | 10:00:00 | 每天定时触发时间 |
|
||||||
|
| 提前触发 | 2s | 开抢前提前 X 秒触发(补偿 RTT) |
|
||||||
|
|
||||||
## 快捷键
|
## 快捷键
|
||||||
|
|
||||||
@@ -86,12 +97,18 @@
|
|||||||
```
|
```
|
||||||
用户点击购买 → 脚本捕获 preview 请求
|
用户点击购买 → 脚本捕获 preview 请求
|
||||||
↓
|
↓
|
||||||
┌── 并发路1 ──┐
|
┌── 极速模式 (前5秒) ──┐
|
||||||
├── 并发路2 ──┤ → 任一获取 bizId
|
│ 10路并发 × 零延迟 │
|
||||||
└── 并发路3 ──┘
|
└──────────────────────┘
|
||||||
|
↓
|
||||||
|
┌── 普通模式 ──────────┐
|
||||||
|
│ 5路并发 × 自适应间隔 │
|
||||||
|
└──────────────────────┘
|
||||||
|
↓
|
||||||
|
任一获取 bizId
|
||||||
↓
|
↓
|
||||||
check 校验 bizId
|
check 校验 bizId
|
||||||
├── EXPIRE → 立即重试
|
├── EXPIRE/空单 → 立即重试
|
||||||
└── 通过 → 成功!
|
└── 通过 → 成功!
|
||||||
↓
|
↓
|
||||||
4 层支付恢复
|
4 层支付恢复
|
||||||
@@ -99,43 +116,80 @@
|
|||||||
├── 缓存响应 + 重点击购买
|
├── 缓存响应 + 重点击购买
|
||||||
├── 直接获取支付链接
|
├── 直接获取支付链接
|
||||||
└── 兜底提醒
|
└── 兜底提醒
|
||||||
|
↓
|
||||||
|
超过 maxRetry 且 < 5分钟
|
||||||
|
↓
|
||||||
|
捡漏模式(2路/3s间隔)
|
||||||
```
|
```
|
||||||
|
|
||||||
## 注意事项
|
|
||||||
|
|
||||||
- 需要先登录智谱账号
|
|
||||||
- 抢购前建议先点一次购买按钮让脚本捕获请求参数
|
|
||||||
- 建议在抢购开始前 3 秒点击 **预热** 按钮
|
|
||||||
- 如果支付弹窗未出现,脚本会自动尝试多种恢复策略
|
|
||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
|
|
||||||
### v4.1 (2026-04-08)
|
### v4.6-mod (2026-04-18)
|
||||||
|
基于 qtaxm/glm-rush v4.6,OpenClaw 新增修改:
|
||||||
|
- **A1** check 返回金额为 0 视为空单,继续重试
|
||||||
|
- **A2** patchSoldOut 增加 Vue 响应式对象保护
|
||||||
|
- **A3** 支持提前触发(补偿 RTT)
|
||||||
|
- **A4** maxRetry 耗尽后自动进入捡漏模式
|
||||||
|
- **A5** 全局 fetch 响应 JSON soldOut/isServerBusy/stock=0 补丁
|
||||||
|
- **B1** Promise.allSettled 统一处理并发取消
|
||||||
|
- **B2** favicon.ico HEAD 时间同步,采样 3 次取中位数
|
||||||
|
- **B3** 预热改空 POST,提前 5 分钟开始
|
||||||
|
- **B4** waitForBuyButton 异步轮询(最多 8 秒)
|
||||||
|
- **B5** stopAll 主动 abort 所有 AbortController
|
||||||
|
- **B6** getVueRoot Vue 2/3 兼容辅助函数
|
||||||
|
- **B7** 支付弹窗出现时重置 recoveryAttempts
|
||||||
|
- **C1** code=555 系统繁忙视为 EXPIRE 立即重试,429 退避上限 8 秒
|
||||||
|
- **C2** 连续售罄改为比例判断(60% 即计数)
|
||||||
|
- **C3** rAF 精度提升,最后 1 秒切换 requestAnimationFrame
|
||||||
|
- **C4** sessionStorage 版本校验(__v:1)
|
||||||
|
- **C5** history 路由劫持,离开时确认
|
||||||
|
- **C6** fakeXHR setProp 双重保护属性赋值
|
||||||
|
- **D1** 面板增加放票时间警告提示
|
||||||
|
- **D2** dismissDialog 优先发送 Escape 事件
|
||||||
|
- **D3** getDelay 参数名语义修正
|
||||||
|
- **D4** VERSION 常量统一版本管理
|
||||||
|
|
||||||
|
### v4.6 (2026-04-10) 原版
|
||||||
|
- **修复** 支付弹窗不弹出 — 根因: 前端 `payComponent.isServerBusy=true` 阻止 `payPreviewFn` 发请求
|
||||||
|
- **新增** `patchSoldOut` 增加 `isServerBusy` 拦截(JSON.parse 层)
|
||||||
|
- **新增** `patchVueServerBusy` 兜底:定时扫描 Vue 组件树,直接 patch `isServerBusy=false`
|
||||||
|
- **新增** `forcePayDialog` 兜底:抢购成功 1.5s 后若弹窗未出现,直接设置 Vue `payDialogVisible=true`
|
||||||
|
|
||||||
|
### v4.5 (2026-04-10) 原版
|
||||||
|
- **修复** `findBuyButton` 找错按钮(匹配到"即刻订阅"导航按钮),优先找 `buy-btn` 类按钮
|
||||||
|
|
||||||
|
### v4.4 (2026-04-09) 原版
|
||||||
|
- **新增** 极速模式:前 5 秒 10 路并发,之后降为 5 路
|
||||||
|
- **新增** 请求指纹随机化(X-Request-Id / X-Timestamp / Accept-Language 权重随机)
|
||||||
|
- **新增** 余额支付方式支持
|
||||||
|
- **优化** 并发数从 3 路提升到 5 路(普通模式)
|
||||||
|
- **优化** 最大重试从 500 提升到 2000
|
||||||
|
- **优化** 爆发次数从 10 提升到 20,快速间隔从 50ms 降到 30ms
|
||||||
|
- **优化** 连续售罄 / 限流智能退避
|
||||||
|
|
||||||
|
### v4.1 (2026-04-08) 原版
|
||||||
- **修复** 售罄状态下按钮不可点击的问题(恢复全局 JSON.parse patch)
|
- **修复** 售罄状态下按钮不可点击的问题(恢复全局 JSON.parse patch)
|
||||||
- **修复** 支付弹窗不弹出的问题(4 层恢复策略:清弹窗→缓存重点击→获取支付链接→兜底提醒)
|
- **修复** 支付弹窗不弹出的问题(4 层恢复策略)
|
||||||
- **修复** `@match` 规则不匹配 `bigmodel.cn`(无 www)的问题
|
- **修复** `@match` 规则不匹配 `bigmodel.cn`(无 www)
|
||||||
- **修复** 原型链污染风险(Object.keys + WeakSet 循环引用保护)
|
- **修复** 原型链污染风险(Object.keys + WeakSet)
|
||||||
- **修复** HTTP 401/403 会话过期检测(之前永远不会触发)
|
- **修复** HTTP 401/403 会话过期检测
|
||||||
- **修复** 限流退避使用错误的计数器
|
- **修复** 限流退避使用错误的计数器
|
||||||
- **修复** stats.errors 永远显示 0
|
- **修复** stats.errors 永远显示 0
|
||||||
- **修复** Alt+H 快捷键在 Shadow DOM 中失效
|
- **修复** Alt+H 快捷键在 Shadow DOM 中失效
|
||||||
- **修复** `_glmShadow` 暴露在全局作用域
|
|
||||||
|
|
||||||
### v4.0 (2026-04-08)
|
### v4.0 (2026-04-08) 原版
|
||||||
- 并发重试(3 路 Promise.race)
|
- 并发重试(Promise.race 变体)
|
||||||
- 自适应间隔(爆发→快速→随机抖动)
|
- 自适应间隔(爆发→快速→随机抖动)
|
||||||
- 反检测(定向拦截、toString 伪装、Shadow DOM)
|
- 反检测(定向拦截、toString 伪装、Shadow DOM)
|
||||||
- 高精度定时(rAF + performance.now)
|
- 高精度定时(rAF + performance.now)
|
||||||
- 配置/请求持久化(localStorage + sessionStorage)
|
- 配置/请求持久化
|
||||||
- MutationObserver 弹窗监控
|
- MutationObserver 弹窗监控
|
||||||
- TCP 预热、快捷键、离开保护
|
- 快捷键、离开保护
|
||||||
|
|
||||||
### v3.2 (原版)
|
|
||||||
- 单线程串行重试
|
|
||||||
- preview + check 双重校验
|
|
||||||
- 错误弹窗自动恢复
|
|
||||||
- 浮动控制面板
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT
|
MIT License
|
||||||
|
|
||||||
|
## 致谢
|
||||||
|
|
||||||
|
- 原作者 [qtaxm/glm-rush](https://github.com/qtaxm/glm-rush)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name 智谱 GLM Coding 抢购助手 v4.0
|
// @name 智谱 GLM Coding 抢购助手 v4.0
|
||||||
// @namespace http://tampermonkey.net/
|
// @namespace http://tampermonkey.net/
|
||||||
// @version 4.4
|
// @version 4.6
|
||||||
// @description 并发重试 + 自适应间隔 + 反检测 + check校验 + 弹窗恢复 + 定时触发 + 配置持久化
|
// @description 并发重试 + 自适应间隔 + 反检测 + check校验 + 弹窗恢复 + 定时触发 + 配置持久化
|
||||||
// @author Assistant
|
// @author Assistant
|
||||||
// @match *://www.bigmodel.cn/*
|
// @match *://www.bigmodel.cn/*
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
const VERSION = '4.6';
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// ═══════════════════════════════════════════
|
// ═══════════════════════════════════════════
|
||||||
@@ -68,11 +69,19 @@
|
|||||||
|
|
||||||
// 恢复上次捕获的请求
|
// 恢复上次捕获的请求
|
||||||
try {
|
try {
|
||||||
const saved = sessionStorage.getItem('glm_rush_captured');
|
const raw = sessionStorage.getItem('glm_rush_captured');
|
||||||
if (saved) state.captured = JSON.parse(saved);
|
if (raw) {
|
||||||
|
const parsed = JSON.parse(raw);
|
||||||
|
if (parsed.__v !== 1) {
|
||||||
|
sessionStorage.removeItem('glm_rush_captured');
|
||||||
|
} else {
|
||||||
|
state.captured = parsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
let stopRequested = false;
|
let stopRequested = false;
|
||||||
|
let _activeControllers = [];
|
||||||
let recovering = false;
|
let recovering = false;
|
||||||
let recoveryAttempts = 0;
|
let recoveryAttempts = 0;
|
||||||
let _shadowRef = null;
|
let _shadowRef = null;
|
||||||
@@ -85,9 +94,9 @@
|
|||||||
const rand = (min, max) => min + Math.random() * (max - min);
|
const rand = (min, max) => min + Math.random() * (max - min);
|
||||||
const jitteredDelay = base => Math.round(base * (1 + (Math.random() * 2 - 1) * CFG.jitter));
|
const jitteredDelay = base => Math.round(base * (1 + (Math.random() * 2 - 1) * CFG.jitter));
|
||||||
|
|
||||||
function getDelay(attempt) {
|
function getDelay(round) {
|
||||||
if (attempt <= CFG.burstCount) return 0;
|
if (round <= CFG.burstCount) return 0;
|
||||||
if (attempt <= 50) return jitteredDelay(CFG.fastDelay);
|
if (round <= 50) return jitteredDelay(CFG.fastDelay);
|
||||||
return jitteredDelay(CFG.slowDelay);
|
return jitteredDelay(CFG.slowDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,9 +125,12 @@
|
|||||||
|
|
||||||
function patchSoldOut(obj, visited = new WeakSet()) {
|
function patchSoldOut(obj, visited = new WeakSet()) {
|
||||||
if (!obj || typeof obj !== 'object' || visited.has(obj)) return;
|
if (!obj || typeof obj !== 'object' || visited.has(obj)) return;
|
||||||
|
if (obj.__ob__ !== undefined) return;
|
||||||
|
if (obj.__v_isVNode || obj.__v_isRef) return;
|
||||||
visited.add(obj);
|
visited.add(obj);
|
||||||
if (obj.isSoldOut === true) obj.isSoldOut = false;
|
if (obj.isSoldOut === true) obj.isSoldOut = false;
|
||||||
if (obj.soldOut === true) obj.soldOut = false;
|
if (obj.soldOut === true) obj.soldOut = false;
|
||||||
|
if (obj.isServerBusy === true) obj.isServerBusy = false;
|
||||||
if (obj.disabled === true && (obj.price !== undefined || obj.productId || obj.title)) obj.disabled = false;
|
if (obj.disabled === true && (obj.price !== undefined || obj.productId || obj.title)) obj.disabled = false;
|
||||||
if (obj.stock === 0) obj.stock = 999;
|
if (obj.stock === 0) obj.stock = 999;
|
||||||
for (const k of Object.keys(obj)) {
|
for (const k of Object.keys(obj)) {
|
||||||
@@ -127,6 +139,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ═══════════════════════════════════════════
|
||||||
|
// Vue 2/3 兼容获取根实例
|
||||||
|
// ═══════════════════════════════════════════
|
||||||
|
function getVueRoot(selector = '#app') {
|
||||||
|
const el = document.querySelector(selector);
|
||||||
|
if (!el) return null;
|
||||||
|
if (el.__vue__) return el.__vue__;
|
||||||
|
if (el.__vue_app__) return el.__vue_app__._instance?.proxy;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// 全局 patch: 页面加载时也需要解除售罄状态,否则按钮不可点击
|
// 全局 patch: 页面加载时也需要解除售罄状态,否则按钮不可点击
|
||||||
JSON.parse = function (text, reviver) {
|
JSON.parse = function (text, reviver) {
|
||||||
const result = _parse(text, reviver);
|
const result = _parse(text, reviver);
|
||||||
@@ -162,8 +185,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const text = await resp.text();
|
const text = await resp.text();
|
||||||
|
// 全局 patch: 对所有 JSON 响应移除售罄/繁忙标记,只在命中时替换
|
||||||
|
const needsPatch = /"isSoldOut":true|"soldOut":true|"isServerBusy":true|"stock":0/.test(text);
|
||||||
|
const patchedText = needsPatch
|
||||||
|
? text
|
||||||
|
.replace(/"isSoldOut":true/g, '"isSoldOut":false')
|
||||||
|
.replace(/"soldOut":true/g, '"soldOut":false')
|
||||||
|
.replace(/"isServerBusy":true/g, '"isServerBusy":false')
|
||||||
|
.replace(/"stock":0/g, '"stock":999')
|
||||||
|
: text;
|
||||||
let data;
|
let data;
|
||||||
try { data = _parse(text); } catch { data = null; }
|
try { data = _parse(patchedText); } catch { data = null; }
|
||||||
|
|
||||||
if (data && data.code === 200 && data.data && data.data.bizId) {
|
if (data && data.code === 200 && data.data && data.data.bizId) {
|
||||||
const bizId = data.data.bizId;
|
const bizId = data.data.bizId;
|
||||||
@@ -179,9 +211,17 @@
|
|||||||
if (checkData && checkData.data === 'EXPIRE') {
|
if (checkData && checkData.data === 'EXPIRE') {
|
||||||
return { ok: false, reason: 'EXPIRE', attempt: attemptNum };
|
return { ok: false, reason: 'EXPIRE', attempt: attemptNum };
|
||||||
}
|
}
|
||||||
|
// 新增:金额为0 = 空单,继续重试
|
||||||
|
const payData = checkData?.data;
|
||||||
|
if (payData) {
|
||||||
|
const amount = payData.amount ?? payData.totalAmount ?? payData.payAmount ?? 0;
|
||||||
|
if (amount === 0) {
|
||||||
|
return { ok: false, reason: '空单(金额为0)', attempt: attemptNum };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 通过!
|
// 通过!
|
||||||
return { ok: true, text, data, bizId, status: resp.status, attempt: attemptNum };
|
return { ok: true, text: patchedText, data, bizId, status: resp.status, attempt: attemptNum };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { ok: false, reason: `check异常: ${e.message}`, attempt: attemptNum };
|
return { ok: false, reason: `check异常: ${e.message}`, attempt: attemptNum };
|
||||||
}
|
}
|
||||||
@@ -222,6 +262,7 @@
|
|||||||
const curConcurrency = isTurbo ? CFG.turboConcurrency : CFG.concurrency;
|
const curConcurrency = isTurbo ? CFG.turboConcurrency : CFG.concurrency;
|
||||||
const batchSize = Math.min(curConcurrency, CFG.maxRetry - totalAttempt);
|
const batchSize = Math.min(curConcurrency, CFG.maxRetry - totalAttempt);
|
||||||
const controllers = [];
|
const controllers = [];
|
||||||
|
_activeControllers = controllers;
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
for (let j = 0; j < batchSize; j++) {
|
for (let j = 0; j < batchSize; j++) {
|
||||||
@@ -252,7 +293,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 收集失败原因 (用于日志)
|
// 收集失败原因 (用于日志)
|
||||||
const results = await Promise.all(promises.map(p => p.catch(() => ({ ok: false, reason: '已取消' }))));
|
const settled = await Promise.allSettled(promises);
|
||||||
|
const failedResults = settled
|
||||||
|
.filter(r => r.status === 'fulfilled' && !r.value.ok && r.value.reason !== '已取消')
|
||||||
|
.map(r => r.value);
|
||||||
|
|
||||||
if (winner) {
|
if (winner) {
|
||||||
setState({
|
setState({
|
||||||
@@ -268,12 +312,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 统计错误
|
// 统计错误
|
||||||
const failedResults = results.filter(r => !r.ok);
|
|
||||||
const reasons = failedResults.map(r => r.reason || '未知');
|
const reasons = failedResults.map(r => r.reason || '未知');
|
||||||
setState({ stats: { ...state.stats, errors: state.stats.errors + failedResults.length } });
|
setState({ stats: { ...state.stats, errors: state.stats.errors + failedResults.length } });
|
||||||
|
|
||||||
const networkErrors = reasons.filter(r => r.startsWith('网络')).length;
|
const networkErrors = reasons.filter(r => r.startsWith('网络')).length;
|
||||||
consecutiveErrors = networkErrors === batchSize ? consecutiveErrors + 1 : 0;
|
consecutiveErrors = (networkErrors > 0 && networkErrors === failedResults.length)
|
||||||
|
? consecutiveErrors + 1 : 0;
|
||||||
|
|
||||||
// 连续网络错误 → 暂停
|
// 连续网络错误 → 暂停
|
||||||
if (consecutiveErrors >= 3) {
|
if (consecutiveErrors >= 3) {
|
||||||
@@ -292,23 +336,23 @@
|
|||||||
// 限流检测 (独立计数)
|
// 限流检测 (独立计数)
|
||||||
if (reasons.some(r => r.includes('429') || r.includes('限流'))) {
|
if (reasons.some(r => r.includes('429') || r.includes('限流'))) {
|
||||||
throttleCount++;
|
throttleCount++;
|
||||||
const backoff = Math.min(2000 * (2 ** Math.min(throttleCount, 4)), 16000);
|
const backoff = Math.min(1000 * (2 ** Math.min(throttleCount, 3)), 8000);
|
||||||
log(`限流, 退避${backoff}ms...`, 'warn');
|
log(`限流, 退避${backoff}ms...`, 'warn');
|
||||||
await sleep(backoff);
|
await sleep(backoff);
|
||||||
} else {
|
} else {
|
||||||
throttleCount = 0;
|
throttleCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPIRE → 立即重试不等待
|
// 只有 EXPIRE 和系统繁忙(555)无延迟立即重试
|
||||||
if (reasons.every(r => r === 'EXPIRE')) continue;
|
if (reasons.every(r => r === 'EXPIRE' || r === '系统繁忙')) continue;
|
||||||
|
|
||||||
// 前20秒全速冲,之后才考虑降速
|
// 前20秒全速冲,之后才考虑降速
|
||||||
const elapsedSec = (performance.now() - state.stats.startTime) / 1000;
|
const elapsedSec = (performance.now() - state.stats.startTime) / 1000;
|
||||||
|
|
||||||
if (elapsedSec > 20) {
|
if (elapsedSec > 20) {
|
||||||
// 超过20秒 — 检测是否该降速
|
// 超过20秒 — 检测是否该降速
|
||||||
const soldOutCount = reasons.filter(r => r === '售罄').length;
|
const soldOutRatio = reasons.filter(r => r === '售罄').length / batchSize;
|
||||||
if (soldOutCount === batchSize) {
|
if (soldOutRatio >= 0.6) {
|
||||||
consecutiveSoldOut++;
|
consecutiveSoldOut++;
|
||||||
} else {
|
} else {
|
||||||
consecutiveSoldOut = 0;
|
consecutiveSoldOut = 0;
|
||||||
@@ -358,6 +402,7 @@
|
|||||||
method: init?.method || 'POST',
|
method: init?.method || 'POST',
|
||||||
body: init?.body,
|
body: init?.body,
|
||||||
headers: extractHeaders(init?.headers),
|
headers: extractHeaders(init?.headers),
|
||||||
|
__v: 1,
|
||||||
};
|
};
|
||||||
setState({ captured });
|
setState({ captured });
|
||||||
try { sessionStorage.setItem('glm_rush_captured', JSON.stringify(captured)); } catch {}
|
try { sessionStorage.setItem('glm_rush_captured', JSON.stringify(captured)); } catch {}
|
||||||
@@ -429,7 +474,7 @@
|
|||||||
|
|
||||||
if (typeof url === 'string' && url.includes(CFG.PREVIEW)) {
|
if (typeof url === 'string' && url.includes(CFG.PREVIEW)) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const captured = { url, method: this._m, body, headers: this._h || {} };
|
const captured = { url, method: this._m, body, headers: this._h || {}, __v: 1 };
|
||||||
setState({ captured });
|
setState({ captured });
|
||||||
try { sessionStorage.setItem('glm_rush_captured', JSON.stringify(captured)); } catch {}
|
try { sessionStorage.setItem('glm_rush_captured', JSON.stringify(captured)); } catch {}
|
||||||
|
|
||||||
@@ -507,22 +552,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dismissDialog(dialog) {
|
function dismissDialog(dialog) {
|
||||||
// 关闭按钮
|
// 只在传入的 dialog 内部查找关闭按钮,不 fallback 到 document(避免关掉支付弹窗)
|
||||||
for (const sel of ['.el-dialog__headerbtn', '.el-message-box__headerbtn', '.ant-modal-close', '[aria-label="Close"]', '[aria-label="close"]']) {
|
for (const sel of ['.el-dialog__headerbtn', '.el-message-box__headerbtn', '.ant-modal-close', '[aria-label="Close"]', '[aria-label="close"]']) {
|
||||||
const btn = dialog.querySelector(sel) || document.querySelector(sel);
|
const btn = dialog.querySelector(sel);
|
||||||
if (btn && btn.offsetParent !== null) { btn.click(); return true; }
|
if (btn && btn.offsetParent !== null) { btn.click(); return true; }
|
||||||
}
|
}
|
||||||
// 确定/取消按钮
|
// 确定/取消按钮(仅 dialog 内部)
|
||||||
for (const btn of dialog.querySelectorAll('button, [role="button"]')) {
|
for (const btn of dialog.querySelectorAll('button, [role="button"]')) {
|
||||||
const t = (btn.textContent || '').trim();
|
const t = (btn.textContent || '').trim();
|
||||||
if (/关闭|确定|取消|知道了|OK|Cancel|Close|确认/.test(t) && t.length < 10) { btn.click(); return true; }
|
if (/关闭|确定|取消|知道了|OK|Cancel|Close|确认/.test(t) && t.length < 10) { btn.click(); return true; }
|
||||||
}
|
}
|
||||||
// Escape
|
// 直接隐藏这个 dialog
|
||||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', keyCode: 27, bubbles: true }));
|
|
||||||
// 遮罩
|
|
||||||
for (const mask of document.querySelectorAll('.el-overlay, .v-modal, [class*="overlay"], [class*="mask"]')) {
|
|
||||||
if (mask.offsetParent !== null || window.getComputedStyle(mask).position === 'fixed') { mask.click(); return true; }
|
|
||||||
}
|
|
||||||
dialog.style.display = 'none';
|
dialog.style.display = 'none';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -530,31 +570,27 @@
|
|||||||
async function autoRecover() {
|
async function autoRecover() {
|
||||||
if (recovering || recoveryAttempts >= CFG.recoveryMax || !state.lastSuccess) return;
|
if (recovering || recoveryAttempts >= CFG.recoveryMax || !state.lastSuccess) return;
|
||||||
|
|
||||||
|
// 如果页面上有支付相关弹窗,不要干扰
|
||||||
|
const payEl = document.querySelector('[class*="pay"], [class*="qrcode"], [class*="wechat"], [class*="alipay"], [class*="cashier"], iframe[src*="pay"]');
|
||||||
|
if (payEl && (payEl.offsetParent !== null || window.getComputedStyle(payEl).position === 'fixed')) {
|
||||||
|
log('支付弹窗已出现, 跳过恢复');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 只处理明确的错误弹窗,不暴力清理所有弹窗
|
||||||
|
const dialog = findErrorDialog();
|
||||||
|
if (!dialog) return;
|
||||||
|
|
||||||
recovering = true;
|
recovering = true;
|
||||||
recoveryAttempts++;
|
recoveryAttempts++;
|
||||||
try {
|
try {
|
||||||
// 策略1: 关闭所有弹窗/遮罩 (暴力清理)
|
log('检测到错误弹窗, 清理中...');
|
||||||
const dialog = findErrorDialog();
|
dismissDialog(dialog);
|
||||||
if (dialog) {
|
await sleep(300);
|
||||||
log('检测到错误弹窗, 清理中...');
|
|
||||||
dismissDialog(dialog);
|
|
||||||
await sleep(300);
|
|
||||||
}
|
|
||||||
// 清理所有可能残留的遮罩层
|
|
||||||
document.querySelectorAll('.el-overlay, .v-modal, .el-overlay-dialog, [class*="overlay"], [class*="mask"]').forEach(el => {
|
|
||||||
el.style.display = 'none';
|
|
||||||
});
|
|
||||||
document.querySelectorAll('.el-dialog__wrapper, .el-message-box__wrapper').forEach(el => {
|
|
||||||
el.style.display = 'none';
|
|
||||||
});
|
|
||||||
// 移除 body 上的 overflow:hidden (弹窗锁定滚动)
|
|
||||||
document.body.style.overflow = '';
|
|
||||||
document.body.classList.remove('el-popup-parent--hidden');
|
|
||||||
await sleep(200);
|
|
||||||
|
|
||||||
// 策略2: 缓存响应 + 重新点购买按钮
|
// 策略2: 缓存响应 + 重新点购买按钮
|
||||||
setState({ cache: state.lastSuccess });
|
setState({ cache: state.lastSuccess });
|
||||||
const btn = findBuyButton();
|
const btn = await waitForBuyButton();
|
||||||
if (btn) {
|
if (btn) {
|
||||||
btn.click();
|
btn.click();
|
||||||
log('已重新点击购买按钮 (策略2)');
|
log('已重新点击购买按钮 (策略2)');
|
||||||
@@ -630,10 +666,17 @@
|
|||||||
// ═══════════════════════════════════════════
|
// ═══════════════════════════════════════════
|
||||||
// 主动抢购 & 定时
|
// 主动抢购 & 定时
|
||||||
// ═══════════════════════════════════════════
|
// ═══════════════════════════════════════════
|
||||||
function findBuyButton() {
|
async function waitForBuyButton(timeout = 8000) {
|
||||||
for (const el of document.querySelectorAll('button, a, [role="button"], div[class*="btn"], span[class*="btn"]')) {
|
const start = Date.now();
|
||||||
const t = el.textContent.trim();
|
while (Date.now() - start < timeout) {
|
||||||
if (/购买|抢购|立即|下单|订阅/.test(t) && t.length < 20 && el.offsetParent !== null) return el;
|
for (const el of document.querySelectorAll('button.buy-btn, button[class*="subscribe"], button[class*="buy"]')) {
|
||||||
|
if (el.offsetParent !== null) return el;
|
||||||
|
}
|
||||||
|
for (const el of document.querySelectorAll('button')) {
|
||||||
|
const t = el.textContent?.trim();
|
||||||
|
if (/^特惠订购$|^立即订购$|^立即购买$/.test(t) && el.offsetParent !== null) return el;
|
||||||
|
}
|
||||||
|
await sleep(200);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -661,10 +704,18 @@
|
|||||||
// 自动通知
|
// 自动通知
|
||||||
try { new Notification('GLM 抢购成功!', { body: `bizId=${state.bizId}` }); } catch {}
|
try { new Notification('GLM 抢购成功!', { body: `bizId=${state.bizId}` }); } catch {}
|
||||||
const errDlg = findErrorDialog();
|
const errDlg = findErrorDialog();
|
||||||
if (errDlg) { dismissDialog(errDlg); await sleep(300); }
|
if (errDlg) {
|
||||||
const btn = findBuyButton();
|
dismissDialog(errDlg);
|
||||||
|
if (errDlg.offsetParent !== null) recoveryAttempts = 0;
|
||||||
|
await sleep(300);
|
||||||
|
}
|
||||||
|
const btn = await waitForBuyButton();
|
||||||
if (btn) { btn.click(); log('已自动点击购买按钮'); }
|
if (btn) { btn.click(); log('已自动点击购买按钮'); }
|
||||||
else { alert('已获取到商品! 请立即点击购买按钮!'); }
|
else { alert('已获取到商品! 请立即点击购买按钮!'); }
|
||||||
|
|
||||||
|
// 兜底: 如果 fakeXHR 没能弹出支付窗口, 直接设置 Vue 数据
|
||||||
|
await sleep(1500);
|
||||||
|
forcePayDialog(result.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,15 +808,15 @@
|
|||||||
const ms = target.getTime() - getServerNow();
|
const ms = target.getTime() - getServerNow();
|
||||||
log(`定时: ${timeStr} (${Math.ceil(ms / 1000)}秒后, 北京时间)`);
|
log(`定时: ${timeStr} (${Math.ceil(ms / 1000)}秒后, 北京时间)`);
|
||||||
|
|
||||||
// 提前3秒自动预热
|
// 提前5分钟自动预热
|
||||||
if (ms > 4000) {
|
if (ms > 310_000) {
|
||||||
setTimeout(() => {
|
setTimeout(preheat, Math.max(0, ms - 300_000));
|
||||||
log('定时前3秒, 自动预热...');
|
|
||||||
preheat();
|
|
||||||
}, Math.max(0, ms - 3000));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 精确等待: 用 setInterval 10ms 检查, 到时间立即启动
|
// 精确等待: 用 setInterval 10ms 检查, 剩余1秒切换 rAF
|
||||||
|
const preAdvanceMs = (CFG.preAdvanceSec || 0) * 1000;
|
||||||
|
let rafCancelled = false;
|
||||||
|
window._glmRafCancelled = () => { rafCancelled = true; };
|
||||||
const tid = setInterval(() => {
|
const tid = setInterval(() => {
|
||||||
const remaining = target.getTime() - getServerNow();
|
const remaining = target.getTime() - getServerNow();
|
||||||
// 更新面板倒计时
|
// 更新面板倒计时
|
||||||
@@ -774,13 +825,26 @@
|
|||||||
const timerEl = _shadowRef?.getElementById('timer-info');
|
const timerEl = _shadowRef?.getElementById('timer-info');
|
||||||
if (timerEl) timerEl.textContent = `-${sec}s`;
|
if (timerEl) timerEl.textContent = `-${sec}s`;
|
||||||
}
|
}
|
||||||
if (remaining <= 0) {
|
if (remaining <= preAdvanceMs) {
|
||||||
clearInterval(tid);
|
clearInterval(tid);
|
||||||
setState({ timerId: null });
|
setState({ timerId: null });
|
||||||
const timerEl = _shadowRef?.getElementById('timer-info');
|
const timerEl = _shadowRef?.getElementById('timer-info');
|
||||||
if (timerEl) timerEl.textContent = '';
|
if (timerEl) timerEl.textContent = '';
|
||||||
log('时间到! 自动启动抢购!');
|
log(`提前 ${CFG.preAdvanceSec}s 触发!`);
|
||||||
startProactive();
|
startProactive();
|
||||||
|
} else if (remaining > 0 && remaining <= 1000) {
|
||||||
|
clearInterval(tid);
|
||||||
|
function rafWait() {
|
||||||
|
if (rafCancelled || stopRequested) return;
|
||||||
|
if (target.getTime() - getServerNow() <= preAdvanceMs) {
|
||||||
|
const timerEl = _shadowRef?.getElementById('timer-info');
|
||||||
|
if (timerEl) timerEl.textContent = '';
|
||||||
|
startProactive();
|
||||||
|
} else {
|
||||||
|
requestAnimationFrame(rafWait);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
requestAnimationFrame(rafWait);
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
@@ -789,20 +853,20 @@
|
|||||||
|
|
||||||
// 预热
|
// 预热
|
||||||
async function preheat() {
|
async function preheat() {
|
||||||
try {
|
log('开始预热连接...');
|
||||||
log('TCP预热中...');
|
let ok = 0;
|
||||||
// 连发3次预热请求,确保连接池暖好
|
for (let i = 0; i < 5; i++) {
|
||||||
for (let i = 0; i < 3; i++) {
|
const r = await _fetch(location.origin + '/favicon.ico', { method: 'HEAD' }).catch(() => null);
|
||||||
await _fetch(location.origin + '/api/biz/pay/check?bizId=preheat_' + i, { credentials: 'include' }).catch(() => {});
|
if (r) ok++;
|
||||||
await sleep(200);
|
|
||||||
}
|
|
||||||
// 也预热 preview 的 DNS + TCP (用 HEAD 请求不产生副作用)
|
|
||||||
await _fetch(location.origin + CFG.PREVIEW, {
|
await _fetch(location.origin + CFG.PREVIEW, {
|
||||||
method: 'HEAD',
|
method: 'POST',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: '{}',
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
log('预热完成 (4次连接已建立)');
|
await sleep(300);
|
||||||
} catch { log('预热部分失败,不影响使用'); }
|
}
|
||||||
|
log(`预热完成:${ok}/5 连接建立成功`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ═══════════════════════════════════════════
|
// ═══════════════════════════════════════════
|
||||||
@@ -821,6 +885,63 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ═══════════════════════════════════════════
|
||||||
|
// Vue isServerBusy 兜底 patch
|
||||||
|
// ═══════════════════════════════════════════
|
||||||
|
function patchVueServerBusy() {
|
||||||
|
let attempts = 0;
|
||||||
|
const tid = setInterval(() => {
|
||||||
|
attempts++;
|
||||||
|
if (attempts > 30) { clearInterval(tid); return; } // 15秒后放弃
|
||||||
|
const app = document.querySelector('#app');
|
||||||
|
const vue = app && app.__vue__;
|
||||||
|
if (!vue) return;
|
||||||
|
let patched = 0;
|
||||||
|
const walk = (vm, depth) => {
|
||||||
|
if (depth > 8) return;
|
||||||
|
if (vm.$data && vm.$data.isServerBusy === true) {
|
||||||
|
vm.isServerBusy = false;
|
||||||
|
patched++;
|
||||||
|
}
|
||||||
|
for (const child of (vm.$children || [])) walk(child, depth + 1);
|
||||||
|
};
|
||||||
|
walk(vue, 0);
|
||||||
|
if (patched > 0) {
|
||||||
|
log(`已解除 isServerBusy (${patched}个组件)`);
|
||||||
|
clearInterval(tid);
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 兜底: 直接操作 Vue 组件弹出支付窗口 */
|
||||||
|
function forcePayDialog(responseData) {
|
||||||
|
const app = document.querySelector('#app');
|
||||||
|
const vue = app && app.__vue__;
|
||||||
|
if (!vue) return;
|
||||||
|
|
||||||
|
let payComp = null;
|
||||||
|
const findComp = (vm, depth) => {
|
||||||
|
if (depth > 8) return;
|
||||||
|
if (vm.$data && 'payDialogVisible' in vm.$data) { payComp = vm; return; }
|
||||||
|
for (const child of (vm.$children || [])) { findComp(child, depth + 1); if (payComp) return; }
|
||||||
|
};
|
||||||
|
findComp(vue, 0);
|
||||||
|
if (!payComp) { log('未找到支付组件'); return; }
|
||||||
|
|
||||||
|
// 已经弹出了就不干预
|
||||||
|
if (payComp.payDialogVisible) { log('支付弹窗已显示'); return; }
|
||||||
|
|
||||||
|
// 设置 priceData 和 payDialogVisible
|
||||||
|
const data = responseData && responseData.data;
|
||||||
|
if (data) {
|
||||||
|
payComp.priceData = data;
|
||||||
|
payComp.payDialogVisible = true;
|
||||||
|
log('兜底: 已直接设置 payDialogVisible=true');
|
||||||
|
} else {
|
||||||
|
log('兜底: 响应数据无 data 字段, 无法设置');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ═══════════════════════════════════════════
|
// ═══════════════════════════════════════════
|
||||||
// 浮动面板 (Shadow DOM)
|
// 浮动面板 (Shadow DOM)
|
||||||
// ═══════════════════════════════════════════
|
// ═══════════════════════════════════════════
|
||||||
@@ -866,7 +987,7 @@
|
|||||||
.keys{font-size:10px;color:#636e72;text-align:center;margin-top:6px}
|
.keys{font-size:10px;color:#636e72;text-align:center;margin-top:6px}
|
||||||
</style>
|
</style>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="hd" id="drag"><b>GLM v4.4</b><button class="mn" id="min">-</button></div>
|
<div class="hd" id="drag"><b>GLM v${VERSION}</b><button class="mn" id="min">-</button></div>
|
||||||
<div class="bd" id="bd">
|
<div class="bd" id="bd">
|
||||||
<div class="st st-idle" id="st">等待中</div>
|
<div class="st st-idle" id="st">等待中</div>
|
||||||
<div class="cap" id="cap">${state.captured ? '已恢复上次捕获的请求' : '请先点一次购买按钮'}</div>
|
<div class="cap" id="cap">${state.captured ? '已恢复上次捕获的请求' : '请先点一次购买按钮'}</div>
|
||||||
@@ -885,6 +1006,7 @@
|
|||||||
<button class="b-time" id="b-time">设定</button>
|
<button class="b-time" id="b-time">设定</button>
|
||||||
<span id="timer-info" style="color:#6c5ce7;font-size:11px"></span>
|
<span id="timer-info" style="color:#6c5ce7;font-size:11px"></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="timer-tip" style="color:#fdcb6e;font-size:11px;margin-bottom:8px">⚠️ 每次确认放票时间</div>
|
||||||
<div class="btns">
|
<div class="btns">
|
||||||
<button class="b-go" id="b-go">▶ 主动抢购</button>
|
<button class="b-go" id="b-go">▶ 主动抢购</button>
|
||||||
<button class="b-stop" id="b-stop" style="display:none">■ 停止</button>
|
<button class="b-stop" id="b-stop" style="display:none">■ 停止</button>
|
||||||
@@ -927,10 +1049,13 @@
|
|||||||
// 闭包引用供 refreshUI 使用
|
// 闭包引用供 refreshUI 使用
|
||||||
_shadowRef = shadow;
|
_shadowRef = shadow;
|
||||||
|
|
||||||
log('v4.4 已加载 (极速并发+时间同步+全自动抢购)');
|
log('v4.5 已加载 (极速并发+时间同步+全自动抢购)');
|
||||||
if (state.captured) log('已恢复上次捕获的请求参数, 可直接设定时间');
|
if (state.captured) log('已恢复上次捕获的请求参数, 可直接设定时间');
|
||||||
setupDialogWatcher();
|
setupDialogWatcher();
|
||||||
|
|
||||||
|
// 兜底: 定时 patch Vue 组件的 isServerBusy (batch-preview 可能在脚本前加载)
|
||||||
|
patchVueServerBusy();
|
||||||
|
|
||||||
// 自动同步服务器时间
|
// 自动同步服务器时间
|
||||||
syncServerTime();
|
syncServerTime();
|
||||||
|
|
||||||
@@ -1010,7 +1135,7 @@
|
|||||||
// ═══════════════════════════════════════════
|
// ═══════════════════════════════════════════
|
||||||
// 启动
|
// 启动
|
||||||
// ═══════════════════════════════════════════
|
// ═══════════════════════════════════════════
|
||||||
console.log('[GLM] v4.0 已注入');
|
console.log(`[GLM] v${VERSION} 已注入`);
|
||||||
if (document.readyState === 'loading') {
|
if (document.readyState === 'loading') {
|
||||||
document.addEventListener('DOMContentLoaded', createPanel);
|
document.addEventListener('DOMContentLoaded', createPanel);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user