Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 

Repository files navigation

⚠️ NOTICE / 提示:This script is still in testing phase. Use at your own risk. / 当前脚本仍处于测试阶段,使用风险自负。


⚠️ DISCLAIMER / 免责声明

This script modifies frontend state to work around UI-level restrictions . These behaviors may be detected by the platform's risk control systems and could result in account flagging, rate limiting, or suspension.

Use entirely at your own risk. The author assumes no responsibility for any consequences, including but not limited to account restrictions or financial loss.


本脚本通过修改前端状态绕过界面级限制。上述行为可能被平台风控系统识别,导致账号被标记、限流加重或封禁

使用本脚本风险完全由您自行承担。 作者不对任何后果负责,包括但不限于账号受限或财产损失。作者不承担因使用本脚本导致的任何资金损失、账号封禁等责任。用户使用前必须理解:脚本修改了网页与服务器的通信数据,可能产生不可预期的订单金额。任何情况下,如果支付页面显示的金额与预期不符,请立即停止支付并关闭页面。


Reporting Issues / 报告问题

If the script fails to identify a plan, the overlay log will show messages like:

[识别] 价格 134.1 精确匹配失败,范围兜底 → pro(原价可能已变,建议更新 PLAN_PRICE_MAP)
[诊断] productList 中存在未知价格: [44.1, 134.1, 422.1] — 若套餐调价请更新 PLAN_PRICE_MAP
[识别失败] 未知价格: 188, productId=xxx — 超出所有已知范围,请更新 PLAN_PRICE_MAP/PLAN_PRICE_RANGES

如果遇到上述日志,请提交 Issue 并附上完整日志截图和目标套餐(Lite / Pro / Max + 计费周期)。 If you see any of these, please open an issue with the full log and your target plan (Lite / Pro / Max, billing period).


English | 中文


GLM Coding Plan Sniper

Auto-purchase script for Zhipu's GLM Coding Plan — automatically places orders at 10:00 AM daily.

Why

GLM Coding Plan releases limited stock at 10:00 AM (UTC+8) daily and sells out within seconds. This script automates the entire flow: intercept sold-out status -> click purchase -> confirm order. All you need to do is scan the QR code to pay.

Features

  • Sold-out Bypass — Intercepts soldOut flags during the purchase window (9:59 ~ 10:30) to enable buttons
  • Fallback Plan Queue — Configure a priority list of plans; if the primary is sold out, the script automatically falls back to the next candidate in order, cycling through all options before giving up
  • Plan Selection — Defaults to Pro + Quarterly billing (configurable via planPriority)
  • Precision Timing — Auto-clicks the purchase button at 10:00:00 with 100ms retry interval, up to 300 retries (30 seconds per round)
  • Auto Confirm — Automatically clicks confirm/pay buttons in popups
  • QR Detection — Plays an alert sound when the payment QR code appears
  • Overlay UI — Real-time countdown, log, and payment safety warning displayed in the top-right corner
  • Auto Refresh — Refreshes the page at 9:59:50 to fetch the latest state
  • API Auto-Retry — Automatically retries failed fetch/XHR requests (429/500/502/503) up to 8 times with incremental delay
  • Smart Modal Protection — Detects CAPTCHA and payment modals by content (not just CSS class), freezes all refresh logic to protect them; auto-resumes when modal disappears
  • Auto Re-trigger — After each retry round or page recovery, automatically re-triggers the purchase flow (no manual intervention needed throughout 10:30)
  • Error Page Recovery — Three-tier recovery when the page shows "too many visitors":
    1. DOM-level suppression: hides the error and re-triggers SPA data loading via pushState/popstate
    2. Full page refresh with cache-busting as fallback
    3. Recovery window covers 10:30, ensuring continued retries
  • productId Persistence — Saves the captured productId to localStorage (12h TTL, isolated by plan/period); restored immediately on page refresh without waiting for API response, eliminating race conditions
  • System Notifications — Sends a browser notification when sold out or when the payment QR appears, so you don't miss it even if the tab is in the background
  • Preconnect Warm-up — Injects <link rel="preconnect"> before the rush to establish TCP/TLS connections at the browser level, faster than fetch HEAD
  • Resilient Plan Matching — Identifies plans by price with exact match first, then falls back to non-overlapping price ranges (Lite: ¥30–80, Pro: ¥100–200, Max: ¥350–550), so discounted prices (e.g. 9折) still match correctly

Two Versions

File Description
glm-coding-sniper.user.js Tampermonkey userscript — runs automatically after installation (recommended)
glm-coding-sniper-console.js Browser console version — paste into F12 Console, fallback when Tampermonkey is unavailable (now feature-complete with Tampermonkey version)

Usage

Tampermonkey (Recommended)

One-click install (v1.4.1): Install Tampermonkey first, then click 👉 Install Script — Tampermonkey will automatically pop up the install page.

Or install manually:

  1. Install the Tampermonkey browser extension
  2. Enable Developer Mode in Chrome (chrome://extensions, top-right toggle)
  3. Create a new script in Tampermonkey, paste the contents of glm-coding-sniper.user.js, and save
  4. Open https://open.bigmodel.cn/glm-coding around 9:55 AM and make sure you're logged in
  5. A black overlay in the top-right corner = script is running
  6. Do not click any buttons manually — let the script handle it
  7. When you hear the beep, scan the QR code to pay immediately

Console Version

  1. Open the purchase page around 9:59 AM and log in
  2. Press F12 -> Console tab
  3. Paste the entire contents of glm-coding-sniper-console.js and press Enter
  4. Overlay appears = success (you'll need to re-paste after any page refresh)

Configuration

Edit the CONFIG object at the top of the script:

const CONFIG = {
  // Priority list of plans to attempt, in order.
  // The first entry is the primary target; subsequent entries are fallbacks.
  // Each entry: { plan: 'lite'|'pro'|'max', billingPeriod: 'monthly'|'quarterly'|'yearly' }
  planPriority: [
    { plan: 'pro', billingPeriod: 'quarterly' },
    // { plan: 'lite', billingPeriod: 'quarterly' }, // fallback (uncomment to enable)
  ],
  targetHour: 10,              // target hour
  targetMinute: 0,             // target minute
  advanceMs: 200,              // ms to start early (compensate network latency)
  retryInterval: 100,          // retry interval in ms
  maxRetries: 300,             // max retry attempts per round (300 * 100ms = 30s)
};

Fallback Plan Example

To try Pro quarterly first, then fall back to Lite quarterly:

planPriority: [
  { plan: 'pro', billingPeriod: 'quarterly' },
  { plan: 'lite', billingPeriod: 'quarterly' },
],

The script cycles through all configured plans. It only stops when every plan has been confirmed sold out for 3 consecutive full cycles — this prevents false positives from brief API fluctuations.

How It Works

This script does not call backend APIs directly. It automates button clicks on the page — all requests are sent by the page's own frontend framework.

Page loads → Intercept soldOut to enable buttons → Auto-click "Subscribe" at 10:00
→ Auto-click confirm popup → CAPTCHA appears (manual) → QR code appears → Scan to pay

If the purchase attempt times out (30 seconds), the script resets and waits for the page to recover, then automatically re-triggers — this cycle repeats throughout 10:30.

If the page shows "too many visitors" error, the script handles it in layers:

API returns 429/5xx → fetch/XHR auto-retry (up to 8 times, incremental delay)
→ If error page still renders → DOM suppression (hide error + pushState re-trigger)
→ If still broken → full page refresh with cache-busting (every 2s, until 10:30)

If a CAPTCHA or payment modal appears, the script detects it by content (verification/payment keywords) and freezes all refresh logic to protect it. Once the modal disappears, auto-purchasing resumes.

The script cannot bypass CAPTCHAs. If a slider or image verification appears after clicking the purchase button, you need to complete it manually. The script's value is:

  1. Speed — clicks at exactly 10:00:00, hundreds of ms faster than a human
  2. Fewer steps — auto-selects billing period, auto-clicks purchase and confirm, you only handle CAPTCHA + payment
  3. Anti-cache — intercepts soldOut flags so buttons don't stay grayed out due to stale frontend state
  4. Resilience — automatically recovers from "too many visitors" errors without manual intervention

Important Notes

  • Overlay not appearing? — Reload the tab (Ctrl+R). The script runs on all open.bigmodel.cn pages so it works regardless of how you navigate to the purchase page.
  • Buttons stay disabled outside the purchase window — sold-out interception only activates during 9:59~11:00
  • Don't open multiple tabs — one is enough, more tabs cause lag
  • Have your payment app ready — QR codes expire quickly
  • Don't pay if the order shows no amount — if the payment QR appears without a price, do not scan it
  • Frontend only — backend inventory validation is unaffected; if it's truly out of stock, the script can't help

Alternatives

If you can't get it after multiple days:

  • International version z.ai — no purchase limits, AFF + annual discount brings the price close to domestic
  • Alibaba Cloud Bailian — call GLM-5.1 directly on-demand, restocks daily at 9:30 AM

Author

hd233yui

License

MIT


English | 中文

GLM Coding Plan 自动抢购脚本

智谱 GLM Coding Plan 自动抢购脚本,每天 10:00 自动下单。

为什么需要

GLM Coding Plan 每天 10:00 限量放货,几秒售罄,纯手动根本抢不到。此脚本自动完成"拦截售罄状态 -> 点击购买 -> 确认订单"全流程,你只需扫码付款。

功能

  • 售罄状态拦截 — 在抢购窗口期(9:59 ~ 10:30)自动将 soldOut 改为 false,让按钮可点击
  • 候补套餐队列 — 可配置多个候补套餐,首选售罄后自动按优先级切换到下一个,走完一整圈仍全售罄才放弃
  • 自动选择套餐 — 默认选择 Pro + 连续包季(可通过 planPriority 配置)
  • 精准定时 — 10:00:00 自动点击购买按钮,100ms 间隔重试,每轮最多 300 次(30秒)
  • 自动确认 — 自动点击弹窗中的确认/支付按钮
  • 二维码检测 — 检测到支付二维码后播放提示音
  • 悬浮窗 — 右上角实时显示倒计时、运行日志和付款安全提示
  • 自动刷新 — 9:59:50 自动刷新页面获取最新状态
  • API 自动重试 — fetch/XHR 请求遇到 429/500/502/503 自动重试最多 8 次,递增延迟
  • 智能弹窗保护 — 通过内容(而非 CSS 类名)检测验证码/支付弹窗,出现时冻结所有刷新逻辑;弹窗消失后自动恢复
  • 自动重新触发 — 每轮重试结束或页面恢复后自动重新发起抢购,10:30无需手动干预
  • 错误页面自动恢复 — "访问人数较多"三级恢复策略:
    1. DOM 级抑制:隐藏错误内容,通过 pushState/popstate 触发 SPA 重新加载数据
    2. 全页面强制刷新(带 cache-busting 参数)兜底
    3. 恢复窗口覆盖10:30,确保持续重试
  • productId 持久化 — 捕获的 productId 写入 localStorage(12小时有效,按套餐/周期隔离),页面刷新后立即恢复,无需等待 API 响应,彻底解决时序竞争问题
  • 系统通知 — 售罄或支付二维码出现时发送浏览器系统通知,标签页在后台也不会错过
  • Preconnect 预热 — 抢购前注入 <link rel="preconnect"> 由浏览器原生建立 TCP/TLS 连接,比 fetch HEAD 更早更高效
  • 套餐价格兜底匹配 — 先通过原价精确匹配套餐,失败时自动降级为价格区间匹配(Lite: ¥30–80,Pro: ¥100–200,Max: ¥350–550),即使 monthlyOriginalAmount 为折后价(如包季9折 ¥134.1)也能正确识别

两个版本

文件 说明
glm-coding-sniper.user.js Tampermonkey 油猴脚本,安装后自动运行,推荐使用
glm-coding-sniper-console.js 浏览器控制台版,直接粘贴到 F12 Console 运行,Tampermonkey 不可用时的备选(已与油猴版功能同步)

使用方法

Tampermonkey 版(推荐)

一键安装 (v1.4.1): 先安装 Tampermonkey,然后点击 👉 安装脚本 — Tampermonkey 会自动弹出安装页面。

或手动安装:

  1. 安装 Tampermonkey 浏览器扩展
  2. 确保 Chrome 已开启开发者模式chrome://extensions 右上角)
  3. 在 Tampermonkey 中创建新脚本,粘贴 glm-coding-sniper.user.js 的内容,保存
  4. 9:55 左右打开 https://open.bigmodel.cn/glm-coding ,确保已登录
  5. 右上角出现黑色悬浮窗 = 脚本运行中
  6. 不要手动点任何按钮,等脚本自动操作
  7. 听到"嘟嘟嘟"提示音后立即扫码付款

控制台版

  1. 9:59 打开购买页面并登录
  2. F12 -> Console 标签
  3. 粘贴 glm-coding-sniper-console.js 全部内容,回车
  4. 看到悬浮窗 = 成功(刷新页面后需重新粘贴

配置

修改脚本顶部 CONFIG 对象:

const CONFIG = {
  // 套餐优先级列表,按顺序尝试;第一个为首选,后续为候补
  // 每项: { plan: 'lite'|'pro'|'max', billingPeriod: 'monthly'|'quarterly'|'yearly' }
  planPriority: [
    { plan: 'pro', billingPeriod: 'quarterly' },
    // { plan: 'lite', billingPeriod: 'quarterly' }, // 候补(取消注释以启用)
  ],
  targetHour: 10,              // 抢购小时
  targetMinute: 0,             // 抢购分钟
  advanceMs: 200,              // 提前多少ms开始(补偿网络延迟)
  retryInterval: 100,          // 重试间隔ms
  maxRetries: 300,             // 每轮最大重试次数(300次 * 100ms = 30秒)
};

候补套餐配置示例

先抢 Pro 包季,售罄后自动切换到 Lite 包季:

planPriority: [
  { plan: 'pro', billingPeriod: 'quarterly' },
  { plan: 'lite', billingPeriod: 'quarterly' },
],

脚本会循环遍历所有已配置套餐。只有当所有套餐连续 3 整圈均已确认售罄时才会停止,单次 API 波动不会触发放弃,避免误判。

工作原理

脚本不会直接调用后端 API,本质上就是替你点按钮,所有请求都由页面前端框架发出。

页面加载 → 拦截 soldOut 让按钮可点 → 10:00 自动点"特惠订阅"
→ 自动点确认弹窗 → 弹出验证码(需手动完成)→ 弹出支付二维码 → 扫码付款

如果本轮重试超时(30秒),脚本会自动重置状态并等待页面恢复后重新触发,10:30持续循环。

如果页面显示"当前访问人数较多",脚本会分层处理:

API 返回 429/5xx → fetch/XHR 自动重试(最多8次,递增延迟)
→ 错误页面仍然渲染 → DOM 级抑制(隐藏错误 + pushState 触发重新加载)
→ 仍然异常 → 全页面强刷(每2秒,带时间戳绕缓存,持续到10:30)

如果出现验证码或支付弹窗,脚本通过内容关键词(验证/滑动/支付等)检测,冻结所有刷新逻辑以保护弹窗;弹窗消失后自动恢复抢购。

脚本无法绕过验证码。 如果点击购买按钮后弹出滑块或图形验证,需要你手动完成。脚本的价值在于:

  1. 抢时间 — 10:00:00 精准点击,比手动快几百毫秒
  2. 省操作 — 自动选包季、自动点购买、自动点确认,你只管过验证码 + 扫码付款
  3. 防缓存 — 拦截 soldOut 状态,防止按钮因前端缓存显示灰色
  4. 抗限流 — "访问人数较多"自动恢复,无需手动刷新

注意事项

  • 悬浮窗没有出现? — 刷新页面(Ctrl+R)。脚本在整个 open.bigmodel.cn 域名下运行,无论从哪里导航到购买页都能正常工作。
  • 非抢购时段点击无效 — 售罄拦截只在 9:59~11:00 窗口期生效,其他时间按钮保持原样
  • 不要开多个标签页 — 一个就够,多了浏览器卡反而慢
  • 提前准备支付 — 把支付宝/微信打开,二维码有效期很短
  • 订单无金额不要付款 — 如果支付二维码出现但订单没有显示金额,请不要扫码
  • 脚本只改前端 — 后端库存校验不受影响,抢不到说明确实没货了

替代方案

如果连续多天抢不到,考虑:

  • 国际版 z.ai — 不限购,AFF + 包年折扣后价格接近国内
  • 阿里云百炼 — 可直接按量调用 GLM-5.1,每日 9:30 补货

作者

hd233yui

License

MIT

About

智谱 GLM Coding Plan 自动抢购脚本 (Tampermonkey + Console)

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages