fix: v4.6 clickButton 直接调用 Vue gotoPayFn() 绕过 disabled

Playwright 实测发现: 解除 DOM disabled 后点击按钮仍无法触发 Vue 事件,
因为 Vue 组件内部有自己的状态控制。
改为直接从按钮向上查找 Vue 实例,调用 gotoPayFn() 方法。
This commit is contained in:
qtaxm
2026-04-10 20:16:02 +08:00
parent ac838303cd
commit 471bc16d80
2 changed files with 19 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
# GLM Coding 抢购助手 v4.5
# GLM Coding 抢购助手 v4.6
智谱 GLM Coding Plan 限时抢购自动化脚本Tampermonkey 油猴脚本)
@@ -87,6 +87,10 @@
## 更新日志
### v4.6 (2026-04-10)
- **修复** clickButton 直接调用 Vue 组件的 `gotoPayFn()` 方法,彻底绕过 disabled 按钮限制
- **验证** Playwright 实测确认 `gotoPayFn()` 能触发完整的 preview + check 流程
### v4.5 (2026-04-10)
- **修复** 支付弹窗不弹出的核心问题:改用"先抢再喂"策略retry 独立抢到 bizId 后缓存响应,再点击按钮让前端正常处理
- **修复** `findBuyButton` 找错按钮(匹配到"即刻订阅"导航按钮),现在按优先级排序,优先找特惠/购买按钮

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @name 智谱 GLM Coding 抢购助手 v4.0
// @namespace http://tampermonkey.net/
// @version 4.5
// @version 4.6
// @description 并发重试 + 自适应间隔 + 反检测 + check校验 + 弹窗恢复 + 定时触发 + 配置持久化
// @author Assistant
// @match *://www.bigmodel.cn/*
@@ -649,15 +649,24 @@
}, true);
function clickButton(btn) {
// 强制解除 disabled 状态(售罄按钮需要解锁才能触发事件
// 优先方案: 直接调用 Vue 组件的 gotoPayFn绕过 disabled 限制
let el = btn;
for (let i = 0; i < 20 && el; i++) {
if (el.__vue__ && el.__vue__.gotoPayFn) {
log('直接调用 Vue gotoPayFn()');
el.__vue__.gotoPayFn();
return;
}
el = el.parentElement;
}
// 降级方案: 强制解除 disabled + DOM 点击
log('未找到 Vue 实例, 降级为 DOM 点击');
if (btn.disabled) {
btn.disabled = false;
btn.classList.remove('is-disabled', 'disabled');
log('已解除按钮 disabled 状态');
}
// 确保 pointer-events 可交互
btn.style.pointerEvents = 'auto';
// 多种方式触发点击确保前端框架Vue/Element UI能响应
btn.focus();
btn.dispatchEvent(new MouseEvent('mousedown', { bubbles: true, cancelable: true }));
btn.dispatchEvent(new MouseEvent('mouseup', { bubbles: true, cancelable: true }));