dsh-qianchuan-toolkit 1.0.35 → 1.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +6 -4
  3. package/assets/live-control/SKILL.md +2 -0
  4. package/assets/live-control/references/01-/350/247/204/345/210/231/345/217/243/345/276/204.md +10 -1
  5. package/assets/live-control/scripts/account-lib.mjs +9 -1
  6. package/assets/live-control/scripts/control.mjs +14 -3
  7. package/assets/live-control/scripts/expr/cancel-modal-sq.js +11 -0
  8. package/assets/live-control/scripts/expr/close-dialog-sq.js +12 -0
  9. package/assets/live-control/scripts/expr/dialog-open-sq.js +7 -0
  10. package/assets/live-control/scripts/expr/dismiss-overlays-sq.js +37 -0
  11. package/assets/live-control/scripts/expr/fill-sq.js +68 -0
  12. package/assets/live-control/scripts/expr/log-rows.js +10 -0
  13. package/assets/live-control/scripts/expr/log-tab-click.js +9 -0
  14. package/assets/live-control/scripts/expr/manifest.json +144 -0
  15. package/assets/live-control/scripts/expr/open-plus-sq.js +40 -0
  16. package/assets/live-control/scripts/expr/page-state-sq.js +15 -0
  17. package/assets/live-control/scripts/expr/pause-info-sq.js +57 -0
  18. package/assets/live-control/scripts/expr/pick-sq.js +51 -0
  19. package/assets/live-control/scripts/expr/plus-rect-sq.js +24 -0
  20. package/assets/live-control/scripts/expr/result-sq.js +21 -0
  21. package/assets/live-control/scripts/expr/row-mode-sq.js +23 -0
  22. package/assets/live-control/scripts/expr/row-state-sq.js +72 -0
  23. package/assets/live-control/scripts/expr/submit-dom-sq.js +16 -0
  24. package/assets/live-control/scripts/expr/submit-rect-sq.js +15 -0
  25. package/assets/live-control/scripts/expr-util.mjs +18 -1
  26. package/assets/live-control/scripts/hourly.mjs +38 -11
  27. package/assets/live-control/scripts/selftest.mjs +24 -5
  28. package/assets/live-control/scripts/start-qc.cmd +5 -0
  29. package/assets/live-control/scripts/store.mjs +40 -4
  30. package/assets/material-align/SKILL.md +88 -0
  31. package/assets/material-align/references/01-/345/214/271/351/205/215/350/247/204/345/210/231/344/270/216/345/255/227/346/256/265/345/217/243/345/276/204.md +60 -0
  32. package/assets/material-align/scripts/align.mjs +284 -0
  33. package/assets/material-align/scripts/db.mjs +154 -0
  34. package/assets/material-align/scripts/xlsx.mjs +304 -0
  35. package/assets/plan-copy/SKILL.md +17 -0
  36. package/assets/plan-copy/references/05-/345/274/271/347/252/227/346/270/205/345/215/225.md +14 -0
  37. package/assets/plan-copy/scripts/batch-copy.sh +117 -0
  38. package/assets/plan-copy/scripts/capture.mjs +4 -2
  39. package/assets/plan-copy/scripts/copy.mjs +69 -5
  40. package/assets/plan-copy/scripts/notify-media.mjs +18 -1
  41. package/assets/plan-copy/scripts/pick-all.mjs +2 -8
  42. package/lib/index.js +6 -0
  43. package/package.json +5 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,78 @@
1
1
  # 更新日志
2
2
 
3
+ ## 1.0.44
4
+
5
+ - **新增「一条一条依次复制」脚本 `assets/plan-copy/scripts/batch-copy.sh`**(2026-12-03 用户要求):
6
+ - 队列文件逐条执行 capture → confirm → delete → all(含素材全选)。常规模式每条出确认图后停下等用户回「确认删除」,再用 `--approved=<TOKEN>` 续跑当前条;用户说「批量复制」时用 `--auto`,免人工确认、每条成功推 QQ + 企业微信。
7
+ - 删除仍强制 confirm 确认单(唯一命中该 ID 的行 + 截图 + TOKEN),`delete` 内部再做唯一行校验;失败停在当条并写 `failed.txt`,不跳过、不换计划。
8
+ - 状态目录 `$QC_WORKDIR/qc/batch/<队列名>/`:`<计划ID>.log` / `.token` / `.done`、`results.tsv`;`--dry` 只跑 capture 验证队列。
9
+ - **`capture.mjs` 增加 `metric` 字段**:从列表行「退款优化周期」读 `1小时/24小时净成交` 写进 `params.metric`,供 batch 决定口径(列表行另有「升级24小时净成交」宣传标签,正则必须锚定「退款优化周期」)。
10
+ - **`notify-media.mjs` 新增 `pushText` 导出与 `--text` 命令行**:batch 逐条推成功通知,推送失败不影响主流程。
11
+ - **`copy.mjs` 看门狗非 `all` 分支 150s → 200s**(materials 曾 129s 卡 popup 被杀);**`pick-all.mjs` 去掉「0 卡片 → 点过滤不良素材刷新」**,无素材抖音号直接按空号跳过(2026-12-03 用户要求)。
12
+
13
+ ## 1.0.43
14
+
15
+ - **修「乘方列表偶发加载不出来 → page-not-ready」**(2026-12-02 17:45 实测:两次刷新各 15s/12s 都没把表格画出来,再重读 12s 仍空,整轮 42.9s 后判 page-not-ready;下一轮点了一下「乘方」导航就恢复了)。
16
+ - `hourly.mjs` 的 `refreshList()` 从「最多刷新 2 次」改为 **3 次**:第 3 次先点顶部导航「乘方」/「全域投放」(`expr/nav-click.js`)强制 SPA 重新初始化,等 1.8s 再刷新;等待时间分别放宽到 18s / 15s / 20s。
17
+ - 第 3 次仍不就绪才判 `page-not-ready`,日志会写明「两次刷新仍未就绪 → 点导航…再刷新一次(第 3 次,等 20s)」。
18
+ - **巡航浏览器启动参数补 4 个反节流项**(`assets/live-control/scripts/start-qc.cmd`):`--disable-background-timer-throttling`、`--disable-renderer-backgrounding`、`--disable-backgrounding-occluded-windows`、`--disable-features=CalculateNativeWinOcclusion`。根因是标签页 `document.hidden=true`(窗口在后台/被遮挡)时 Chrome 会节流渲染与定时器,正好表现为表格十几秒画不出来。
19
+ - 注:已启动的浏览器需**重启一次**才会带上新参数;用桌面快捷方式或 `start-qc.cmd` 启动都会带。
20
+
21
+ ## 1.0.42
22
+
23
+ - **新增「分时段控量标准」**(2026-12-02 用户定的规则):`rules.hourly.windows` 支持按时间窗口覆盖门槛与预算,`{ from:'17:00', to:'20:00', minCost:150, roiFloor:2.6, budget:120 }`;时间段左闭右开,`to` 允许 `24:00`,跨零点(如 23:00-02:00)按环绕处理。窗口外的时段回落基础值(`roiFloor`/`minCost`/`budget`)。
24
+ - `store.mjs` 新增 `activeWindow(rule, now)`:返回当前生效的 `{minCost, roiFloor, budget, controlHours, window}`;`resolveRule` 归一化并校验 `windows`(非法 `HH:MM` 丢弃);`judgeHourly(target, hour, rule, now)` 按当前时刻取窗口,返回里带 `window` 与 `eff` 便于回溯,reason 文案补「消耗 X ≤ 门槛 Y(窗口 …)」「ROI X ≥ Y(窗口 …)」。
25
+ - `hourly.mjs`:判定日志追加「[窗口 17:00-20:00:门槛 150 / ROI<2.6 / 预算 120 元]」;`rounds.jsonl` 的 `rule` 记生效值 + 窗口;`--doctor` 逐窗口打印规则(例:`窗口 17:00-20:00:消耗>150 且 ROI<2.6 → 控 120 元 / 0.5 小时`)。
26
+ - 配置(本机 `qc-live/prod/targets.json` 已按用户口径落盘):基础 2.6/200/200;**17:00-20:00 消耗>150 且 ROI<2.60 → 控 120 元/0.5h**;**20:00-24:00 消耗>200 且 ROI<2.60 → 控 200 元/0.5h**;窗口外(含 00:00-01:00)用基础值。
27
+ - `selftest.mjs` 新增 10 条窗口用例(17:30 控 120、16:59 不控、19:59/20:00 边界、21:00 控 200、23:59 在窗口、ROI 恰 2.6 不控、窗口外回落基础值),全部 37 条通过。
28
+
29
+ ## 1.0.41
30
+
31
+ - **新增技能 `qianchuan-material-align`(素材上传对齐查验)**:纯离线核对、不碰浏览器。输入一张素材上传对齐表(日期 / 视频链接 / 达人昵称 / 带货产品 / 品牌),输出每行「已添加 / 未添加」,已添加的给出命中计划 ID、计划名称、添加时间。
32
+ - **两个关键**:① 历史加投记录当数据库——newmat 每次跑完写的 `$QC_WORKDIR/newmat/records-<aavid>.csv`,`scripts/db.mjs build` 汇总成 `align/db.json`(去重口径:计划ID + 昵称 + 文案 + 发布时间);② 判据是「抖音昵称 + 视频文案片段」是否命中,分五级:L1 文案前缀精确 / L2 片段包含 / L3 前 12 字兜底 / L4 LCS 相似度 ≥0.72 / L5 昵称不一致-文案命中,后三级在报表里标「建议抽查」。
33
+ - `scripts/align.mjs check <对齐表.xlsx>` 输出三张表(核对结果 / 未添加清单 / 统计),支持 `--exclude=<时间前缀>` 剔除崩溃批次未提交记录、`--db` 指定库、`--records=DIR` 追加记录目录、`--sim` 调相似度阈值。
34
+ - `scripts/xlsx.mjs` 是零依赖 xlsx 读写(自写 zip/CRC32 + sheet XML + styles),不引入第三方包;Excel 日期序列号自动转 `yyyy-mm-dd`。
35
+ - 实测(2026-12-02,80 行 × 262 条记录):`ALIGN rows=80 added=51 missing=29`,51 条全部走「文案前缀精确」,分产品 绷带水2.0 29/8、控油洁面 9/9、绷带油 13/10、绷带水乳2.0 0/2。
36
+ - **口径边界**:结论是「有没有出现在我们的自动加投记录里」,不等于「素材弹窗里现在没有这张卡」——人工加过、或加投时已是选中态(脚本不重复点)的视频会落成「未添加」,要坐实需进弹窗逐张核对(属页面动作,单独授权)。
37
+ - 明确不采用抖音作品ID(aweme_id)对齐千川素材ID——两套号,用户 2026-12-02 否决。
38
+
39
+ ## 1.0.40
40
+
41
+ - **新增「净成交口径」设置(24 小时 / 1 小时)**:创编页营销目标卡片里 ROI 右侧是单选 `label.aurora-qc-radio-button-wrapper`(文本「1小时净成交金额」/「24小时净成交金额」,选中态 class 含 `-checked`,平台默认 1 小时)。`copy.mjs` 新增 `METRIC24`、`metricProbe()`、`ensureMetric24()`,在 `focusAndType(BUDGET_INPUT…)`(约 :361)之后默认强制切到 **24小时净成交金额**;要保留 1 小时时用 `QC_METRIC=1h`(日志记 `metric24 skip(1h)`)。切换用 CDP 真实鼠标,点后轮询 `-checked`,未生效最多重试 3 次(日志 `metric24-retry att=N`),最终失败抛「净成交口径没能切到「24小时净成交金额」」。按用户 2026-12-02 规则:**默认口径参考原计划**(看列表行退款优化周期),原计划是 1 小时就带 `QC_METRIC=1h`。
42
+ - **修「口径切不过去」真因:P3 火萤引导弹窗**:创编页 1–3s 内浮出的气泡(标题「24小时净成交优化目标已上线,让目标更贴近实际结算结果」,正文含综合营销ROI = 24小时净成交金额 ÷ 综合成本)压住营销目标卡片,把口径单选的鼠标点击吃掉,表现是连点多次仍 `metric24 fail`。该气泡在火萤组件 `firefly-react-content` 的 shadowRoot 内 `div.firefly-popper-content`,按钮 `div.firefly-content__button` 的 `textContent`=「我知道了」而 `innerText` 为空 → 只能按 `textContent` 匹配 + CDP 真实鼠标点。`ensureMetric24` 改为先 `dismissBubbles(page,0)`、`sleep(700)` 再探测。弹窗清单已在 `references/05-弹窗清单.md` 登记 P3。
43
+ - 实测(2026-12-02):1883249743385620 → 新 1883433372929129(24 小时,`metric24 ok(clicked)`,素材共 83,ALL-EXIT=0,193.7s);1882904543489368 → 新 1883434744412491(`metric24 ok(clicked)`,共 75,322.3s);1883254024799275 → 新 1883435704379722(原计划 1 小时,`metric24 skip(1h)`,共 63,MAT-EXIT=0)。
44
+
45
+ ## 1.0.39
46
+
47
+ - **修乘方日志核对第二步仍失败(`no-log-rows`)**:1.0.38 把详情页地址改对后,13:42:34 那笔控量页头能读到计划ID了,但 `plan-log.js` 在详情页里「点日志tab→等表格」写在一个 async evaluate 里,而点 tab 会让千川 SPA 换路由、销毁执行上下文 → `Runtime.evaluate` 直接卡到 20s 超时(探针复现:`CdpError: cdp 超时 20s:Runtime.evaluate`),12s 轮询拿不到结果,记为 `no-log-rows`。
48
+ - 改法:日志读取拆成**两段式**。新增 `expr/log-tab-click.js`(只点「日志」返回 `CLICKED`/`NO_TAB`,立即返回)与 `expr/log-rows.js`(纯读 `tbody tr`,不点击不等待,返回 `{url,hasOp,rows}`);`hourly.mjs` 新增 `readLogRows(page)`:先读一次(可能已经在日志页),没有再点 tab、等 1.8s、再轮询 5s,最多 2 轮,然后才判失败。`verifyLog` 改为调用它(`hourly.mjs:341` 起)。
49
+ - 只读复核(2026-12-01 13:45):复用巡航标签页导航到 `overall-prom/detail`,页头 2.8s 读到 `{"adId":"1865511384134871","uniqueId":"SHESYEA","name":"奢思雅官方旗舰店"}`,两段式读日志在 **8.4s** 拿到首行 `2026-12-01 13:42:36 新建 操作: 一键控量 控量预算: 200.00元 控量时长: 0.5小时 控量开始时间: 2026年12月01日 13时42分36秒`(对应 13:42:34 提交,+2s)。
50
+ - `expr/manifest.json` 登记 `log-rows`、`log-tab-click` 两条。
51
+
52
+ ## 1.0.38
53
+
54
+ - **修「提交成功但日志核对不一致」误报(2026-12-01 11:41,乘方 200 元控量实际已生效)**:日志核对把详情页地址写死成 `https://qianchuan.jinritemai.com/uni-prom/detail?aavid=…&adId=…`,乘方的详情页在 `overall-prom/detail?aavid=…&adId=…&campaignType=1`;拿全域详情地址去开乘方计划落不到详情,页头没有「计划ID」→ 12s 超时报 `{"err":"no-detail-head"}`,告警文案变成「提交成功但日志核对不一致」。
55
+ - 改法:`assets/live-control/scripts/account-lib.mjs` 的 `detailUrl` 改为 entry 感知——`detailUrl(acct, adId)`,`acct.entry === 'square'` 用 `overall-prom/detail…&campaignType=1`,否则 `uni-prom/detail`;传字符串时按全域处理(兼容旧调用)。`hourly.mjs` 三个调用点(补计划名 :108、日志核对 :341、读最近控量 :439)改为传 `acct`。
56
+ - 只读复核(2026-12-01 11:46):在 `overall-prom/detail` 上 `admap-head.js` 返回 `{"adId":"1865511384134871","uniqueId":"SHESYEA","name":"奢思雅官方旗舰店"}`;`plan-log.js` 首行即 `2026-12-01 11:41:07 新建 操作: 一键控量 控量预算: 200.00元 控量时长: 0.5小时 控量开始时间: 2026年12月01日 11时41分07秒`,与 `submittedAt` `2026-12-01T03:41:06.730Z` 相差 +0.27s,预算/时长/时间三项应全部通过。
57
+
58
+ ## 1.0.37
59
+
60
+ - **修乘方(`overall-prom?campaignType=1`)一键控量全部提交失败**(2026-12-01 10:33:09 / 10:36:19 连续 3 次,10:36:30 已报 QQ+企业微信):乘方的调控弹窗类名是 `aurora-qc-modal-wrap / aurora-qc-modal-confirm / aurora-qc-modal-body`,**不含 `ovui-modal`**,而注入片段只认 `.ovui-modal,[role=dialog]` → `dialog-open.js` 恒为 false,被判「弹窗没起来」;点 `+` 其实每次都成功。
61
+ - 做法:**全域片段一个都不动**(保留原脚本),为乘方单独做 15 份变体 `expr/<name>-sq.js`:dialog-open / fill / submit-dom / submit-rect / close-dialog / cancel-modal / dismiss-overlays / result / page-state / pause-info / pick / plus-rect / open-plus / row-state / row-mode;选择器统一补 `[class*="aurora-qc-modal"]`,遮罩补 `[class*="aurora-qc-modal-mask"]`,footer 补 `[class*="footer-"]`。
62
+ - **「一键调速」组类名也变了**:乘方在控量中/新样式下是 `div.liveSpeedContent-*`(内含 `div.title-*` 文字「一键调速」+ `iconPauseFilled`),旧选择器只认 `[class*="assistTask"]` → `pick.js` 的 `speedGroup()` 返回 null,`hasPlus/hasPause` 全 false,报 `code 3 no plus icon`。15 份变体的组查询统一追加 `[class*="liveSpeedContent"]`。
63
+ - **乘方弹窗是两段式**:先选「调控工具」卡片(一键调速 / 素材人群追投 / 搜索抢首屏),点「一键调速」后才出现「调控方式」单选与预算/时长输入。`fill-sq` 改为 async:先点工具卡片(文案以「一键调速」开头且含「额外付出预算」),轮询等 `[class*=radio-item]` 的「一键控量」,点选后再轮询等两个数字输入框,最后填预算/时长。
64
+ - **弹窗判定文案**:乘方弹窗里没有「调控方式」四个字(第一阶段只有「新建调控任务 / 调控工具」),所以 sq 变体一律用 `/调控方式|新建调控任务/`;`dismiss-overlays-sq` 的 BUSINESS 也加「新建调控任务」,避免把自己刚打开的弹窗关掉。
65
+ - `fill-sq` 的 okMode 放宽为 `/调控(总)?预算/`:乘方文案是「调控总预算」,「调控预算」只出现在解释句里。
66
+ - `result-sq` 提交后轮询最多 3.5s:乘方弹窗是 `aurora-qc-fade-leave` 淡出,900ms 时还在 DOM 里,旧逻辑会误报 `dialogGone=false`。
67
+ - `expr-util.mjs` 新增 `setExprVariant(v)` / `exprVariant()`:`expr(name)` 有变体时优先读 `<name>-<v>.js`,没有对应变体(如日志核对片段)自动回退基础文件。
68
+ - 接线:`hourly.mjs` 的 `pageFor(acct)` 按 `acct.entry === 'square'` 切 `sq`(读列表与提交两条路径都经过它);`control.mjs` 新增 `--entry square`(选标签页优先 `/overall-prom/`,列表 URL 用 `listUrl({entry:'square'})`,否则会去 uni-prom 找行报 `NO_ROW`)。
69
+ - 真实提交验证(2026-12-01 11:09:48):`control.mjs --entry square --aweme 奢思雅官方旗舰店 --budget 200` 走通「点 + → 弹窗已打开 → 点「一键调速」卡片 → 调控方式=一键控量 → 预算 200 / 0.5 小时 → DOM 点「提交」」,页面回 toast「操作成功」,行内变 ⏸,`暂停/停止控量` 弹窗读到控量时间 11:09:50 ~ 11:39:50、预算 200 元;`actions.jsonl` 记 `ok:true code:0 stage:done`。
70
+
71
+ ## 1.0.36
72
+
73
+ - **修 `dismissBubbles` 关不掉火萤引导气泡**(用户 2026-12-01 08:16 批准):旧实现按 `innerText` 匹配,而火萤气泡 `DIV.firefly-content__button` 的 `innerText` 为空、文字只在 `textContent` → 恒返回 `none`,气泡遮挡页面把后续点击吞掉。现改为遍历 `textContent`(含 `shadowRoot`)+ 取命中元素中面积最小者 + **CDP 真实鼠标点击**(JS `.click()` 对火萤无效),点完 700ms 复检并递归,最多 4 层。
74
+ - 影响面:只动 `assets/plan-copy/scripts/copy.mjs`(新增 `clickAt`,重写 `dismissBubbles`),5 处调用点不变。
75
+ - 实测样本(2026-12-01 07:54):气泡文案「乘方支持查看 24 小时净成交指标啦!」,跳过 @(1640,202) 56×24、下一步 @(1696,202) 68×24,文字仅在 textContent。
3
76
  ## 1.0.35
4
77
 
5
78
  - **新增 `assets/plan-copy/scripts/newmat.mjs`:投放中计划「达人新发布素材」自动加投**(用户 2026-11-30 需求,先在临时副本里做了多轮实测,确认后并入)。判据=「添加视频」弹窗卡片上的 `createtime`(视频发布时间)落在近 N 天(默认 5)**且该卡未勾选**;超过窗口的未勾选素材不补,只计入 stale。
package/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # dsh-qianchuan-toolkit
2
2
 
3
- 一个 DSH 技能包,装两个千川技能:
3
+ 一个 DSH 技能包,装三个千川技能:
4
4
 
5
5
  | 技能 | 干什么 |
6
6
  |---|---|
7
7
  | `qianchuan-live-control` | 直播盯盘 + 一键控量:在自然小时的 :15/:30/:45/:55 读分时数据,当前小时消耗**超过 200 元**且净成交 ROI 低于阈值,就给该抖音号提交一键控量(默认 200 元 / 0.5 小时),提交后回读计划日志核对。 |
8
8
  | `qianchuan-plan-copy` | 乘方「推商品」计划复制:搜原计划 → 抓参数 → 确认 → 删除 → 按参数重建 → 逐抖音号全选主页素材 → 核对。 |
9
+ | `qianchuan-material-align` | 素材上传对齐查验:把「对齐表」逐行与本地加投历史记录比对(抖音昵称 + 文案片段),判断每条素材有没有加进计划,输出已添加/未添加报表。纯离线,不用浏览器。 |
9
10
 
10
- 两个技能的脚本各自独立(都在自己的 `assets/*/scripts/` 下),只依赖 Node 18+ 内置模块和一个带调试端口的浏览器。
11
+ 三个技能的脚本各自独立(都在自己的 `assets/*/scripts/` 下),只依赖 Node 18+ 内置模块和一个带调试端口的浏览器。
11
12
 
12
13
  ## 为什么是「账号 × 抖音号」
13
14
 
@@ -30,7 +31,7 @@ npm install dsh-qianchuan-toolkit
30
31
  config: {}
31
32
  ```
32
33
 
33
- 装好后技能目录里出现 `qianchuan-live-control` 与 `qianchuan-plan-copy` 两个技能,不需要重启。
34
+ 装好后技能目录里出现 `qianchuan-live-control`、`qianchuan-plan-copy`、`qianchuan-material-align` 三个技能,不需要重启。
34
35
 
35
36
  ## 上手(live-control)
36
37
 
@@ -76,9 +77,10 @@ node assets/live-control/scripts/hourly.mjs --watch
76
77
  ## 目录
77
78
 
78
79
  ```
79
- lib/index.js 注册两个技能
80
+ lib/index.js 注册三个技能
80
81
  assets/live-control/ SKILL.md + scripts/ + references/ + config.rules.json
81
82
  assets/plan-copy/ SKILL.md + references/ + scripts/
83
+ assets/material-align/ SKILL.md + references/ + scripts/(素材上传对齐查验)
82
84
  locale/ 插件市场文案
83
85
  docs/DETAIL.md 插件详情
84
86
  docs/notify.sample.json 通知配置示例
@@ -32,6 +32,8 @@
32
32
 
33
33
  三层覆盖(优先级低→高):`targets.json` 的 `defaults.hourly` → `accounts[].rules.hourly` → `targets[].rules.hourly`,字段:`nodes / roiFloor / minCost / budget / controlHours`。
34
34
 
35
+ 还可以用 `windows` 按时间段覆盖门槛与预算,例如 `{"from":"17:00","to":"20:00","minCost":150,"roiFloor":2.6,"budget":120}`:左闭右开、`to` 允许 `24:00`、跨零点按环绕处理;落在窗口内用窗口值,窗口外回落上面的基础值。`--doctor` 会逐条打印窗口规则。
36
+
35
37
  ## 2. 数据口径
36
38
 
37
39
  列表页只给当日累计,没法回答「这个小时怎么样」。技能直接调页面自己的分时接口(同源 fetch,带登录态):
@@ -51,7 +51,16 @@
51
51
  defaults.hourly → accounts[].rules.hourly → targets[].rules.hourly
52
52
  ```
53
53
 
54
- 可覆盖字段:`nodes` / `roiFloor` / `minCost` / `budget` / `controlHours`。
54
+ 可覆盖字段:`nodes` / `roiFloor` / `minCost` / `budget` / `controlHours` / `windows`。
55
+
56
+ `windows` 是「分时段标准」数组,每项 `{ from, to, minCost, roiFloor, budget, controlHours }`,左闭右开、`to` 可为 `24:00`、跨零点按环绕处理;窗口内用窗口值,窗口外回落基础值。例:
57
+
58
+ ```json
59
+ "windows": [
60
+ { "from": "17:00", "to": "20:00", "minCost": 150, "roiFloor": 2.6, "budget": 120 },
61
+ { "from": "20:00", "to": "24:00", "minCost": 200, "roiFloor": 2.6, "budget": 200 }
62
+ ]
63
+ ```
55
64
 
56
65
  典型用法:
57
66
 
@@ -10,7 +10,15 @@ import { expr } from './expr-util.mjs'
10
10
  import { sleep, connect, listPages, createTab } from './cdp-lib.mjs'
11
11
  import { ensureLoaded, pollUntil, dismissOverlays } from './page-lib.mjs'
12
12
 
13
- export const detailUrl = (aavid, adId) => 'https://qianchuan.jinritemai.com/uni-prom/detail?aavid=' + aavid + '&adId=' + adId
13
+ // 详情页地址必须跟产品线一致:乘方(campaignType=1)的详情在 overall-prom/detail,
14
+ // 拿 uni-prom/detail 去开乘方计划会落不到详情(页头没有计划ID)→ 日志核对报 no-detail-head。
15
+ export const detailUrl = (acct, adId) => {
16
+ const aavid = typeof acct === 'string' ? acct : acct.aavid
17
+ const square = typeof acct === 'string' ? false : acct.entry === 'square'
18
+ return square
19
+ ? 'https://qianchuan.jinritemai.com/overall-prom/detail?aavid=' + aavid + '&adId=' + adId + '&campaignType=1'
20
+ : 'https://qianchuan.jinritemai.com/uni-prom/detail?aavid=' + aavid + '&adId=' + adId
21
+ }
14
22
  export const listUrl = (acct) => acct.entry === 'square'
15
23
  ? 'https://qianchuan.jinritemai.com/overall-prom?aavid=' + acct.aavid + '&campaignType=1'
16
24
  : 'https://qianchuan.jinritemai.com/uni-prom?aavid=' + acct.aavid
@@ -5,8 +5,10 @@
5
5
  // 时长固定 0.5 小时(平台口径,不接受配置)。退出码:0 成功;2 参数/定位失败;3 页面结构不符;4 状态不允许
6
6
  import fs from 'node:fs'
7
7
  import path from 'node:path'
8
- import { connect } from './cdp-lib.mjs'
8
+ import { connect, listPages } from './cdp-lib.mjs'
9
9
  import { runControl } from './control-lib.mjs'
10
+ import { setExprVariant } from './expr-util.mjs'
11
+ import { listUrl } from './account-lib.mjs'
10
12
  import { homeDir } from './store.mjs'
11
13
 
12
14
  const argv = process.argv.slice(2)
@@ -18,15 +20,24 @@ const BUDGET = Number(arg('budget', '200'))
18
20
  const DRY = flag('dry-run')
19
21
  const SHOTS = arg('shots', homeDir())
20
22
  const A_AVID = arg('aavid', '')
23
+ const ENTRY = arg('entry', '') // 乘方传 --entry square,脚本会自动切 expr/*-sq.js 变体
21
24
 
22
25
  if (!AWEME) { console.error('缺少 --aweme'); process.exit(2) }
23
26
  if (!(BUDGET > 0)) { console.error('--budget 必须 > 0'); process.exit(2) }
24
27
 
25
28
  fs.mkdirSync(SHOTS, { recursive: true })
26
29
  const LOG = path.join(SHOTS, 'actions.jsonl')
27
- const page = await connect('jinritemai')
30
+ setExprVariant(ENTRY === 'square' ? 'sq' : '')
31
+ // 优先连「本账号」标签页:带上 aavid 才不会抢到别的账号或登录页
32
+ const SQUARE = ENTRY === 'square'
33
+ const pages = await listPages()
34
+ const cands = pages.filter((p) => p.type === 'page' && /qianchuan\.jinritemai\.com/.test(p.url || '') && (!A_AVID || (p.url || '').includes('aavid=' + A_AVID)))
35
+ const pref = SQUARE ? /\/overall-prom/ : /\/uni-prom/
36
+ const want = cands.find((p) => pref.test(p.url || '')) || cands[0] || null
37
+ const page = want ? await connect('jinritemai', { id: want.id }) : await connect('jinritemai')
28
38
  console.log('页面', page.url.split('?')[0])
29
- const r = await runControl(page, { aweme: AWEME, budget: BUDGET, shots: SHOTS, dryRun: DRY, aavid: A_AVID, say: (m) => console.log(m) })
39
+ const LURL = listUrl({ entry: SQUARE ? 'square' : 'uni-prom', aavid: A_AVID })
40
+ const r = await runControl(page, { aweme: AWEME, budget: BUDGET, shots: SHOTS, dryRun: DRY, aavid: A_AVID, listUrl: LURL, say: (m) => console.log(m) })
30
41
  fs.appendFileSync(LOG, JSON.stringify(Object.assign({ ts: new Date().toISOString(), dryRun: DRY }, r)) + '\n')
31
42
  if (!r.ok) { console.error('失败', r.code, r.stage, r.err || ''); page.close(); process.exit(r.code || 1) }
32
43
  console.log(DRY ? 'DRY-RUN 完成(未提交)' : '提交完成 ' + r.submittedAt + ' dialogGone=' + r.dialogGone)
@@ -0,0 +1,11 @@
1
+ // 乘方(campaignType=1)专用变体:弹窗类名 aurora-qc-modal*;「一键调速」组在控量中/可调速时是 liveSpeedContent-*。
2
+ // 与同名全域版本并存,由 expr-util.setExprVariant("sq") 在乘方账号轮次自动选用。
3
+ (() => {
4
+ const c = (s) => (s || '').replace(/\s+/g, ' ').trim()
5
+ const m = [...document.querySelectorAll('.ovui-modal,[role=dialog],[class*="aurora-qc-modal"]')].pop()
6
+ if (!m) return 'none'
7
+ const b = [...m.querySelectorAll('button')].find((x) => c(x.innerText) === '取消')
8
+ if (!b) return 'no-cancel'
9
+ b.click()
10
+ return 'canceled'
11
+ })()
@@ -0,0 +1,12 @@
1
+ // 乘方(campaignType=1)专用变体:弹窗类名 aurora-qc-modal*;「一键调速」组在控量中/可调速时是 liveSpeedContent-*。
2
+ // 与同名全域版本并存,由 expr-util.setExprVariant("sq") 在乘方账号轮次自动选用。
3
+ (() => {
4
+ const c = (s) => (s || '').replace(/\s+/g, ' ').trim()
5
+ const shown = (e) => { if (!e) return false; const b = e.getBoundingClientRect(); const cs = getComputedStyle(e); return b.width > 50 && b.height > 50 && cs.visibility !== 'hidden' && cs.display !== 'none' }
6
+ const d = [...document.querySelectorAll('.ovui-modal, [role=dialog], [class*="aurora-qc-modal"]')].filter((x) => shown(x) && /调控方式|新建调控任务/.test(c(x.innerText)))[0]
7
+ if (!d) return 'none'
8
+ const b = [...d.querySelectorAll('button')].find((x) => c(x.innerText) === '取消')
9
+ if (!b) return 'no-cancel'
10
+ b.click()
11
+ return 'canceled'
12
+ })()
@@ -0,0 +1,7 @@
1
+ // 乘方(campaignType=1)专用变体:弹窗类名 aurora-qc-modal*;「一键调速」组在控量中/可调速时是 liveSpeedContent-*。
2
+ // 与同名全域版本并存,由 expr-util.setExprVariant("sq") 在乘方账号轮次自动选用。
3
+ (() => {
4
+ const c = (s) => (s || '').replace(/\s+/g, ' ').trim()
5
+ const shown = (e) => { const b = e.getBoundingClientRect(); const cs = getComputedStyle(e); return b.width > 100 && b.height > 100 && cs.visibility !== 'hidden' && cs.display !== 'none' }
6
+ return [...document.querySelectorAll('.ovui-modal, [role=dialog], [class*="aurora-qc-modal"]')].some((d) => shown(d) && /调控方式|新建调控任务/.test(c(d.innerText)))
7
+ })()
@@ -0,0 +1,37 @@
1
+ // 乘方(campaignType=1)专用变体:弹窗类名 aurora-qc-modal*;「一键调速」组在控量中/可调速时是 liveSpeedContent-*。
2
+ // 与同名全域版本并存,由 expr-util.setExprVariant("sq") 在乘方账号轮次自动选用。
3
+ (() => {
4
+ // 关掉与控量无关的弹窗(推广/升级/引导)。绝不碰含「调控方式」的业务弹窗。
5
+ const c = (s) => (s || '').replace(/\s+/g, ' ').trim()
6
+ const vis = (e) => { const b = e.getBoundingClientRect(); const cs = getComputedStyle(e); return b.width > 20 && b.height > 20 && cs.display !== 'none' && cs.visibility !== 'hidden' && cs.opacity !== '0' }
7
+ const visSmall = (e) => { const b = e.getBoundingClientRect(); const cs = getComputedStyle(e); return b.width >= 6 && b.height >= 6 && cs.display !== 'none' && cs.visibility !== 'hidden' }
8
+ const BUSINESS = /调控方式|新建调控任务|一键控量|控量预算/
9
+ const overlays = [...document.querySelectorAll('.ovui-modal,[role=dialog],[class*="modal"],[class*="dialog"],[class*="aurora-qc-modal"]')]
10
+ .filter((e) => vis(e) && e.getBoundingClientRect().width > 200 && e.getBoundingClientRect().height > 120)
11
+ .filter((e, i, a) => a.indexOf(e) === i)
12
+ .filter((e) => !BUSINESS.test(c(e.innerText)))
13
+ const result = { closed: [], remaining: [], mask: 0, tried: 0 }
14
+ for (const ov of overlays) {
15
+ const title = c(ov.innerText).slice(0, 40)
16
+ if (!title) continue
17
+ result.tried++
18
+ const cands = [
19
+ ...ov.querySelectorAll('[class*="close"],[class*="Close"],[aria-label*="close"],[aria-label*="关闭"]'),
20
+ ...ov.querySelectorAll('iconpark-icon'),
21
+ ].filter((x) => visSmall(x) && x.getBoundingClientRect().width < 120)
22
+ const iconClose = cands.find((x) => /close/i.test((x.getAttribute('name') || '') + ' ' + (x.className || '')))
23
+ const btn = iconClose || cands.find((x) => ['×', '✕', 'x', 'X', '关闭'].includes(c(x.innerText)))
24
+ if (btn) { btn.click(); result.closed.push(title) } else result.remaining.push(title)
25
+ }
26
+ result.mask = [...document.querySelectorAll('.ovui-popup__mask, [class*="aurora-qc-modal-mask"],[class*="mask"]')].filter(vis).length
27
+ const still = [...document.querySelectorAll('.ovui-modal,[role=dialog],[class*="aurora-qc-modal"]')].filter((e) => vis(e) && c(e.innerText).length > 10 && !BUSINESS.test(c(e.innerText)))
28
+ result.stillOpen = still.length
29
+ // 只剩遮罩、没有任何可见弹窗时,把遮罩藏掉,否则全屏遮罩会吞掉后面的点击
30
+ const anyDlg = [...document.querySelectorAll('.ovui-modal,[role=dialog],[class*="aurora-qc-modal"]')].filter((e) => vis(e) && c(e.innerText).length > 10)
31
+ if (!anyDlg.length) {
32
+ let cleared = 0
33
+ for (const m of [...document.querySelectorAll('.ovui-popup__mask, [class*="aurora-qc-modal-mask"]')]) { if (vis(m)) { m.style.display = 'none'; cleared++ } }
34
+ result.maskCleared = cleared
35
+ }
36
+ return JSON.stringify(result)
37
+ })()
@@ -0,0 +1,68 @@
1
+ // 乘方(campaignType=1)专用变体:弹窗类名 aurora-qc-modal*;「一键调速」组在控量中/可调速时是 liveSpeedContent-*。
2
+ // 乘方弹窗是两段式:先选「调控工具」卡片(一键调速/素材人群追投/搜索抢首屏),点「一键调速」后才出现「调控方式」单选与预算/时长输入。
3
+ (async () => {
4
+ const clean = (s) => (s || '').replace(/\s+/g, ' ').trim()
5
+ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
6
+ const shown = (e) => { const b = e.getBoundingClientRect(); return b.width > 100 && b.height > 100 && getComputedStyle(e).display !== 'none' }
7
+ const visIn = (e) => !!e && e.getBoundingClientRect().width > 0 && getComputedStyle(e).display !== 'none'
8
+ const hit = (e) => { const b = e.getBoundingClientRect(); if (!b.width) return false; const t = document.elementFromPoint(b.x + b.width / 2, b.y + b.height / 2); return !!t && (t === e || e.contains(t)) }
9
+ const radioOf = (d) => [...d.querySelectorAll('[class*=radio-item]')].filter((r) => clean(r.innerText) === '一键控量')[0] || null
10
+ const cands = () => [...document.querySelectorAll('.ovui-modal, [class*="aurora-qc-modal"]')].filter((d) => shown(d) && /调控方式|新建调控任务/.test(clean(d.innerText)))
11
+ const first = cands()
12
+ if (!first.length) return JSON.stringify({ err: 'NO_DIALOG', cands: 0 })
13
+ let dlg = first.filter((d) => radioOf(d))[0] || null
14
+ let stage = 'direct'
15
+ // 第一阶段:只有工具卡片。点「一键调速」卡片(文案以「一键调速」开头、含「额外付出预算」)
16
+ if (!dlg) {
17
+ const pick = first[first.length - 1]
18
+ const cards = [...pick.querySelectorAll('div')].filter((e) => {
19
+ const t = clean(e.innerText); const b = e.getBoundingClientRect()
20
+ return /^一键调速/.test(t) && t.includes('额外付出预算') && b.width > 120 && b.height > 40 && b.width < 420
21
+ }).sort((a, b) => a.getBoundingClientRect().width - b.getBoundingClientRect().width)
22
+ const card = cards[0] || null
23
+ if (!card) return JSON.stringify({ err: 'NO_TOOL_CARD', n: first.length })
24
+ card.click()
25
+ stage = 'tool-card'
26
+ for (let i = 0; i < 24 && !dlg; i++) { await wait(150); dlg = cands().filter((d) => radioOf(d))[0] || null }
27
+ }
28
+ if (!dlg) return JSON.stringify({ err: 'NO_KONG_RADIO', stage })
29
+ const kong = radioOf(dlg)
30
+ if (/disabled/.test(String(kong.className))) return JSON.stringify({ err: 'KONG_DISABLED', cls: String(kong.className) })
31
+ kong.click()
32
+ let nums = []
33
+ for (let i = 0; i < 24; i++) {
34
+ await wait(150)
35
+ nums = [...dlg.querySelectorAll('input')].filter((x) => visIn(x) && !/任务名称|ROI/.test(x.placeholder || ''))
36
+ if (nums.length >= 2) break
37
+ }
38
+ if (nums.length < 2) return JSON.stringify({ err: 'NO_INPUTS', n: nums.length, ph: nums.map((i) => i.placeholder) })
39
+ const setInput = (el, v) => {
40
+ const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set
41
+ el.focus()
42
+ setter.call(el, String(v))
43
+ el.dispatchEvent(new Event('input', { bubbles: true }))
44
+ el.dispatchEvent(new Event('change', { bubbles: true }))
45
+ el.blur()
46
+ }
47
+ setInput(nums[0], '{{BUDGET}}')
48
+ setInput(nums[1], '{{HOURS}}')
49
+ await wait(300)
50
+ const text = clean(dlg.innerText)
51
+ const foot = dlg.querySelector('.ovui-modal__footer, [class*="footer-"]')
52
+ const btns = (foot ? [...foot.querySelectorAll('button')] : [...dlg.querySelectorAll('button')]).filter(visIn)
53
+ const submit = btns.filter((b) => clean(b.innerText) === '提交').reverse().find(hit) || btns.filter((b) => clean(b.innerText) === '提交')[0] || null
54
+ const r = submit ? submit.getBoundingClientRect() : null
55
+ const nameEl = [...dlg.querySelectorAll('input')].filter((i) => /任务名称/.test(i.placeholder || ''))[0]
56
+ return JSON.stringify({
57
+ okMode: /调控(总)?预算/.test(text) && text.includes('调控时长'),
58
+ mode: /调控(总)?预算/.test(text) ? '一键控量' : '一键起量',
59
+ budget: nums[0].value,
60
+ hours: nums[1].value,
61
+ name: nameEl ? nameEl.value : '(自动生成)',
62
+ dlgRect: (() => { const b = dlg.getBoundingClientRect(); return [Math.round(b.x), Math.round(b.y), Math.round(b.width), Math.round(b.height)] })(),
63
+ submitHit: submit ? hit(submit) : false,
64
+ submit: r ? { x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) } : null,
65
+ stage,
66
+ tip: text.includes('3~5分钟生效')
67
+ })
68
+ })()
@@ -0,0 +1,10 @@
1
+ // 纯读:不点击、不等待,只把当前 DOM 里的日志表格读出来(配合 log-tab-click.js 两段式使用)。
2
+ (() => {
3
+ const clean = (s) => (s || '').replace(/\s+/g, ' ').trim()
4
+ const trs = [...document.querySelectorAll('tbody tr')].filter((t) => t.querySelectorAll('td').length >= 4)
5
+ const list = trs.slice(0, 8).map((t) => {
6
+ const td = [...t.querySelectorAll('td')].map((x) => clean(x.innerText))
7
+ return { time: td[0], type: td[1], content: td[2], operator: td[3] || '' }
8
+ })
9
+ return JSON.stringify({ url: location.href.slice(0, 120), hasOp: document.body.innerText.includes('操作时间'), rows: list })
10
+ })()
@@ -0,0 +1,9 @@
1
+ // 只负责点「日志」tab,立刻返回:点击会让千川 SPA 换路由、销毁执行上下文,
2
+ // 所以不能在同一个 evaluate 里等日志表格出来(会卡到 CDP 超时)。
3
+ (() => {
4
+ const clean = (s) => (s || '').replace(/\s+/g, ' ').trim()
5
+ const tab = [...document.querySelectorAll('div,span,a,li')].filter((e) => e.children.length === 0 && clean(e.innerText) === '日志')[0]
6
+ if (!tab) return 'NO_TAB'
7
+ tab.click()
8
+ return 'CLICKED'
9
+ })()
@@ -19,6 +19,24 @@
19
19
  ],
20
20
  "placeholders": []
21
21
  },
22
+ {
23
+ "name": "log-rows",
24
+ "file": "expr/log-rows.js",
25
+ "purpose": "纯读详情页日志表格(不点击不等待),配合 log-tab-click 两段式读日志",
26
+ "usedBy": [
27
+ "hourly.mjs"
28
+ ],
29
+ "placeholders": []
30
+ },
31
+ {
32
+ "name": "log-tab-click",
33
+ "file": "expr/log-tab-click.js",
34
+ "purpose": "只点「日志」tab 后立刻返回(点击会换路由销毁执行上下文,不能在同一 evaluate 里等结果)",
35
+ "usedBy": [
36
+ "hourly.mjs"
37
+ ],
38
+ "placeholders": []
39
+ },
22
40
  {
23
41
  "name": "cancel-modal",
24
42
  "file": "expr/cancel-modal.js",
@@ -208,6 +226,132 @@
208
226
  "control-lib.mjs"
209
227
  ],
210
228
  "placeholders": []
229
+ },
230
+ {
231
+ "name": "cancel-modal-sq",
232
+ "file": "expr/cancel-modal-sq.js",
233
+ "purpose": "乘方变体:关含「调控方式」的弹窗(弹窗类名 aurora-qc-modal*)",
234
+ "usedBy": [
235
+ "control-lib.mjs"
236
+ ],
237
+ "placeholders": []
238
+ },
239
+ {
240
+ "name": "close-dialog-sq",
241
+ "file": "expr/close-dialog-sq.js",
242
+ "purpose": "乘方变体:同上,更宽松,返回 none/no-cancel/canceled",
243
+ "usedBy": [
244
+ "hourly.mjs",
245
+ "control-lib.mjs"
246
+ ],
247
+ "placeholders": []
248
+ },
249
+ {
250
+ "name": "dialog-open-sq",
251
+ "file": "expr/dialog-open-sq.js",
252
+ "purpose": "乘方变体:判断控量弹窗是否已出现(认 aurora-qc-modal*)",
253
+ "usedBy": [
254
+ "control-lib.mjs"
255
+ ],
256
+ "placeholders": []
257
+ },
258
+ {
259
+ "name": "dismiss-overlays-sq",
260
+ "file": "expr/dismiss-overlays-sq.js",
261
+ "purpose": "乘方变体:关无关弹窗,同时认 aurora-qc-modal 遮罩",
262
+ "usedBy": [
263
+ "page-lib.mjs"
264
+ ],
265
+ "placeholders": []
266
+ },
267
+ {
268
+ "name": "fill-sq",
269
+ "file": "expr/fill-sq.js",
270
+ "purpose": "乘方变体:选「一键控量」并填预算/时长;文案是「调控总预算」,okMode 用正则兼容",
271
+ "usedBy": [
272
+ "control-lib.mjs"
273
+ ],
274
+ "placeholders": ["{{BUDGET}}", "{{HOURS}}"]
275
+ },
276
+ {
277
+ "name": "page-state-sq",
278
+ "file": "expr/page-state-sq.js",
279
+ "purpose": "乘方变体:页面就绪度/弹窗/遮罩快照(认 aurora-qc-modal*)",
280
+ "usedBy": [
281
+ "page-lib.mjs"
282
+ ],
283
+ "placeholders": []
284
+ },
285
+ {
286
+ "name": "pause-info-sq",
287
+ "file": "expr/pause-info-sq.js",
288
+ "purpose": "乘方变体:读「停止控量」弹窗里的起止时间与预算",
289
+ "usedBy": [
290
+ "hourly.mjs"
291
+ ],
292
+ "placeholders": ["{{BUDGET}}", "{{HOURS}}"]
293
+ },
294
+ {
295
+ "name": "result-sq",
296
+ "file": "expr/result-sq.js",
297
+ "purpose": "乘方变体:读提交后的 toast 与弹窗是否消失",
298
+ "usedBy": [
299
+ "control-lib.mjs"
300
+ ],
301
+ "placeholders": []
302
+ },
303
+ {
304
+ "name": "submit-dom-sq",
305
+ "file": "expr/submit-dom-sq.js",
306
+ "purpose": "乘方变体:DOM 点击「提交」",
307
+ "usedBy": [
308
+ "control-lib.mjs"
309
+ ],
310
+ "placeholders": []
311
+ },
312
+ {
313
+ "name": "submit-rect-sq",
314
+ "file": "expr/submit-rect-sq.js",
315
+ "purpose": "乘方变体:「提交」按钮坐标(坐标兜底路径)",
316
+ "usedBy": [
317
+ "control-lib.mjs"
318
+ ],
319
+ "placeholders": []
320
+ },
321
+ {
322
+ "name": "pick-sq",
323
+ "file": "expr/pick-sq.js",
324
+ "purpose": "乘方变体:读「一键调速」组(认 liveSpeedContent-*)判断可加号/控量中",
325
+ "usedBy": ["hourly.mjs","control.mjs","control-lib.mjs"],
326
+ "placeholders": []
327
+ },
328
+ {
329
+ "name": "plus-rect-sq",
330
+ "file": "expr/plus-rect-sq.js",
331
+ "purpose": "乘方变体:「+」按钮坐标",
332
+ "usedBy": ["control-lib.mjs"],
333
+ "placeholders": []
334
+ },
335
+ {
336
+ "name": "open-plus-sq",
337
+ "file": "expr/open-plus-sq.js",
338
+ "purpose": "乘方变体:DOM 点「+」打开调控弹窗",
339
+ "usedBy": ["control-lib.mjs"],
340
+ "placeholders": []
341
+ },
342
+ {
343
+ "name": "row-state-sq",
344
+ "file": "expr/row-state-sq.js",
345
+ "purpose": "乘方变体:整行状态(消耗/ROI/预算/模式),认 liveSpeedContent-* 组",
346
+ "usedBy": ["hourly.mjs"],
347
+ "placeholders": []
348
+ },
349
+ {
350
+ "name": "row-mode-sq",
351
+ "file": "expr/row-mode-sq.js",
352
+ "purpose": "乘方变体:单行 mode(plus/pause/none/unknown)",
353
+ "usedBy": ["control-lib.mjs"],
354
+ "placeholders": []
211
355
  }
212
356
  ]
213
357
  }
@@ -0,0 +1,40 @@
1
+ // 乘方(campaignType=1)专用变体:弹窗类名 aurora-qc-modal*;「一键调速」组在控量中/可调速时是 liveSpeedContent-*。
2
+ // 与同名全域版本并存,由 expr-util.setExprVariant("sq") 在乘方账号轮次自动选用。
3
+ (() => {
4
+ const c = (s) => (s || '').replace(/\s+/g, ' ').trim()
5
+ const all = [...document.querySelectorAll('tbody tr')].filter((t) => t.querySelectorAll('td').length >= 7)
6
+ const head = all.find((t) => [...t.querySelectorAll('td')].some((td) => c(td.innerText) === '抖音号'))
7
+ const heads = head ? [...head.querySelectorAll('td')].map((td) => c(td.innerText)) : []
8
+ const col = (name, dflt) => { const i = heads.findIndex((h) => h === name); return i >= 0 ? i : dflt }
9
+ const iAweme = col('抖音号', 1), iStatus = col('投放状态', 2), iTool = col('调控工具', 4)
10
+ const isData = (t) => t !== head && !/^共\d+条计划/.test(c(t.innerText))
11
+ const dataRows = all.filter(isData)
12
+ const groupsOf = (td) => [...(td ? td.querySelectorAll('[class*="assistTask"],[class*="assist-task"],[class*="liveSpeedContent"]') : [])]
13
+ const labelOf = (g) => c((g.querySelector('[class*="taskLabel"],.title') || g).innerText).slice(0, 20)
14
+ const DISABLED = /icon-not-allowed|actionIconDisabled/
15
+ // 「一键调速」组类名不稳定(.interfere-tool-wrapper / .assist-task / .assistTask-*),按组内文案定位
16
+ const speedGroup = (td) => {
17
+ if (!td) return null
18
+ const gs = [...td.querySelectorAll('.interfere-tool-wrapper,[class*="assistTask"],[class*="assist-task"],[class*="liveSpeedContent"]')]
19
+ const byText = gs.find((g) => /一键调速/.test(c(g.innerText)))
20
+ if (byText) return byText
21
+ // 绝不退回「第一个含图标的组」:素材/人群追投组里也有 iconpark-icon(含 ⏸),
22
+ // 退回去会把「素材追投暂停」当成「控量中」,点它还弹不出控量弹窗(2026-11-20 11:15 事故根因)
23
+ const byCls = td.querySelector('.interfere-tool-wrapper')
24
+ if (byCls && !/素材|人群|搜索/.test(c(byCls.innerText))) return byCls
25
+ return null
26
+ }
27
+ const want = '{{AWEME}}'
28
+ const hit = dataRows.filter((t) => { const td = t.querySelectorAll('td'); return td[iAweme] && c(td[iAweme].innerText).includes(want) })[0]
29
+ if (!hit) return 'NO_ROW'
30
+ const toolCell = hit.querySelectorAll('td')[iTool]
31
+ // 只点「一键调速」组里的加号,别落到「素材/人群追投」组
32
+ const g0 = speedGroup(toolCell)
33
+ if (!g0) return 'NO_SPEED_GROUP'
34
+ const plus = g0.querySelector('iconpark-icon[name="oc-icon-plus"]')
35
+ if (g0.querySelector('iconpark-icon[name="iconPauseFilled"]')) return 'PAUSE_RUNNING'
36
+ if (!plus) return 'NO_PLUS'
37
+ if (DISABLED.test(plus.className || '')) return 'PLUS_DISABLED'
38
+ plus.click()
39
+ return 'CLICKED'
40
+ })()
@@ -0,0 +1,15 @@
1
+ // 乘方(campaignType=1)专用变体:弹窗类名 aurora-qc-modal*;「一键调速」组在控量中/可调速时是 liveSpeedContent-*。
2
+ // 与同名全域版本并存,由 expr-util.setExprVariant("sq") 在乘方账号轮次自动选用。
3
+ (() => {
4
+ const c = (s) => (s || '').replace(/\s+/g, ' ').trim()
5
+ const vis = (e) => { const b = e.getBoundingClientRect(); const cs = getComputedStyle(e); return b.width > 20 && b.height > 20 && cs.display !== 'none' && cs.visibility !== 'hidden' }
6
+ const overlays = [...document.querySelectorAll('.ovui-modal,[role=dialog],[class*="aurora-qc-modal"]')].filter(vis).map((e) => c(e.innerText).slice(0, 36))
7
+ return JSON.stringify({
8
+ readyState: document.readyState,
9
+ hasBody: !!document.body,
10
+ url: location.href.slice(0, 80),
11
+ overlays,
12
+ spins: [...document.querySelectorAll('.ovui-spin-spinning,[class*="spin-dot"]')].filter(vis).length,
13
+ mask: [...document.querySelectorAll('.ovui-popup__mask, [class*="aurora-qc-modal-mask"]')].filter(vis).length
14
+ })
15
+ })()