with one click
js-wechat-mp-ops-skill
微信公众号后台分析只读 skill,覆盖"用户分析 + 图文(内容)分析"两个板块。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
微信公众号后台分析只读 skill,覆盖"用户分析 + 图文(内容)分析"两个板块。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | js-wechat-mp-ops-skill |
| description | 微信公众号后台分析只读 skill,覆盖"用户分析 + 图文(内容)分析"两个板块。 |
| version | 0.5.0 |
| metadata | {"openclaw":{"emoji":"📊","homepage":"https://github.com/imjszhang/js-eyes","requires":{"skills":["js-eyes"],"bins":["node"]},"platforms":["mp.weixin.qq.com"]}} |
面向微信公众号后台 mp.weixin.qq.com 的只读分析 skill。首版覆盖:
/misc/useranalysis):用户增长 + 用户属性/misc/appmsganalysis):近期图文列表 + 单篇图文详情和 js-wechat-ops-skill 形成 reader / author backend 互补:
js-wechat-ops-skill:阅读者视角,读 mp.weixin.qq.com/s/<id> 文章页js-wechat-mp-ops-skill:作者后台视角,读 mp.weixin.qq.com/misc|cgi-bin/... 分析页两者职责分明、并存不合并。
js-eyes server start)https://mp.weixin.qq.com/misc/appmsganalysis?...(内容分析)https://mp.weixin.qq.com/misc/useranalysis?...(用户分析)allowRawEval:bridge 首次注入时会走一次 bot.executeScript(rawSource),之后每次工具调用只执行 window.__jse_mp_*__.<method>()。
~/.js-eyes/config/config.json 里 security.allowRawEval: trueAllow Raw Eval 打开RAW_EVAL_DISABLED。本 skill 的所有工具都会被归入以下三档之一。审计界线按「是否改微信侧业务数据」而非「是否触网」来划:
纯读,不改任何 DOM、不改 URL、不触发任何业务写操作。
fetchCgiBin(path, params) 重放已有登录凭证的 GET XHR(仅取数据)js_eyes_execute_script: confirm consent(除首次 bridge 注入)wechat_mp_user_overview / wechat_mp_user_attrs / wechat_mp_content_list / wechat_mp_content_list_all / wechat_mp_content_detail / wechat_mp_content_summary / wechat_mp_content_trend / wechat_mp_content_sources / wechat_mp_content_tables_dump只改浏览器自己筛选态/导航,不改微信侧任何业务数据。实现硬约束:
location.assign(newUrl) 方式切换 URL / query,禁止模拟点击任何 DOM CTA{from, to, hint},由调用方再 state() 做自校验skill.contract.js 里带 interactive: true / destructive: false 两个字段wechat_mp_content_navigate / wechat_mp_user_navigate任何改微信侧业务数据、生成导出文件、触发订阅变化的操作,v0.1+ 一直不会做:
skill.contract.js 里把该工具标记 destructive: true,并要求调用方显式 --confirm 走 Safe Default Mode consent 流程。| 档位 | 工具 | 页面 | 说明 |
|---|---|---|---|
| READ | wechat_mp_user_overview | /misc/useranalysis?1=1 | 用户增长概况:每日新增/取消/净增关注 + 累计总数 |
| READ | wechat_mp_user_attrs | /misc/useranalysis?action=attr | 用户属性:性别/年龄/地域/终端(关注数 < 100 时返回 ready:false) |
| READ | wechat_mp_content_list | /misc/appmsganalysis?action=report | 近期发表图文列表 + 阅读人数/占比 + msgid/publish_date |
| READ | wechat_mp_content_list_all | /misc/appmsganalysis?action=report | 列表全量(不设 limit 默认)+ paginator 信息(总页/每页/总条数) |
| READ | wechat_mp_content_summary | /misc/appmsganalysis | 子 tab + 日期范围 + 顶部 KPI 卡 + paginator 摘要(用于快速自检) |
| READ | wechat_mp_content_trend | /misc/appmsganalysis | 走 get_article_stat_tendency_and_source:每日各场景 read_uv / share_uv(scene=9999 为合计)。v0.4 起支持可选 msgid / publishDate,端点会按单篇维度返回 |
| READ | wechat_mp_content_sources | /misc/appmsganalysis | 复用同一 XHR 的 all_article_stat_source.list:各来源渠道聚合。v0.4 起支持可选 msgid / publishDate |
| READ | wechat_mp_content_tables_dump | /misc/appmsganalysis | 调试用:按表头 + 前 N 行 dump 当前页所有表格,便于踩点改版 |
| READ | wechat_mp_content_detail | /misc/appmsganalysis?action=detailpage | 单篇图文 KPI + 地域表 + v0.4 新增 charts 字段(9 张 Highcharts 全提取):readTrend / readChannel / subscribeFunnel(阅读后关注漏斗)/ shareTrans(分享转化)/ shareTrend / shareChannel(分享去向)/ gender / age / map(地域)。全部走 SVG <text> 解析,不依赖私有 XHR |
| INTERACTIVE | wechat_mp_content_navigate | /misc/appmsganalysis | 仅通过 location.assign 修改 URL 参数(切子 tab / 切日期 / 跳详情页);绝不模拟点击。v0.4 起 action ∈ {report,all,detailpage}、front_type ∈ {空,without_notice},传 download_summary_tendency 直接拒绝 |
| INTERACTIVE | wechat_mp_user_navigate | /misc/useranalysis | v0.5 新增。仅通过 location.assign 切换 user-analysis 子 tab:action ∈ {attr,activity_analysis_page},clear=true 回 "用户增长" 默认 tab;不模拟点击 |
全部工具都是 optional: true(按需加载),入参详见 skill.contract.js::TOOL_DEFINITIONS。
skill.contract.js,仅供本仓库开发者排查)下面两条只在 CLI 暴露、不暴露给 AI tool 列表,用于改版后定位 DOM 结构变化或抓 XHR 形态:
| CLI | 用途 |
|---|---|
node index.js content-detail-dump [--anchors] [--with-outer-html] | 一次性 snapshot detailpage 上的关键 DOM 节点([id*=js_] / <dl> / <table> / .data_list / [class*=card] / Highcharts 容器),输出 tag/class/role + text outline;--anchors 加锚点链接清单,--with-outer-html 顺带每节点首屏 outerHTML(仅本地调试用) |
node index.js content-xhr-log [--filter <substr>] | 读 performance.getEntriesByType('resource'),过滤 mp.weixin.qq.com/misc/appmsganalysis 命中条目,按 action 聚合并解析 querystring(最多 30 个参数),用来判断改版后端点是否新增 |
这两条不写 listener、不挂 hook,纯靠浏览器内置 buffer,可放心反复跑。
cd /Volumes/home_x/github/my/js-wechat-mp-ops-skill
npm install
# 通路 + 登录态 + bridge 注入 + probe + state 一站诊断
node index.js doctor
# 用户增长(默认 --page user-analysis)
node index.js user-overview --range 30d
# 用户属性
node index.js user-attrs
# v0.5:用户分析子 tab 导航(INTERACTIVE,仅改 URL)
node index.js user-navigate --to-action attr # 切到"用户属性"
node index.js user-navigate --to-action activity_analysis_page # 切到"常读用户分析"
node index.js user-navigate --clear # 回"用户增长" tab
# 近期图文列表
node index.js content-list --limit 10
# 单篇详情(先在浏览器里切到 detailpage URL;v0.4 起返回阅读时长 / 完读率 / 分享去向等)
node index.js content-detail 2247484081_1 2026-04-14
# v0.4:单篇维度的趋势 / 来源(在 trend 端点上加 msgid/publish_date)
node index.js content-trend --range 7d --msgid 2247484081_1 --publish-date 2026-04-14
node index.js content-sources --range 7d --msgid 2247484081_1 --publish-date 2026-04-14
# v0.4:内部踩点(仅本仓库开发者用)
node index.js content-detail-dump --anchors
node index.js content-xhr-log
# 也可通过 js-eyes 统一入口
js-eyes skill run js-wechat-mp-ops-skill doctor
CLI / Tool call
└── skill.contract.js (createRuntime / TOOL_DEFINITIONS)
└── lib/session.js (connect → resolveTarget → ensureBridge → callApi)
├── lib/config.js PAGE_PROFILES
├── lib/js-eyes-client.js BrowserAutomation (token-auth)
└── bridges/*-bridge.js + bridges/common.js (@@include)
└── DOM read | fetchCgiBin replay
| profile | targetUrlFragment | bridgeGlobal | bridgePath |
|---|---|---|---|
content-analysis | mp.weixin.qq.com/misc/appmsganalysis | __jse_mp_content__ | bridges/content-analysis-bridge.js |
user-analysis | mp.weixin.qq.com/misc/useranalysis | __jse_mp_user__ | bridges/user-analysis-bridge.js |
每个 bridge 顶部维护 const VERSION = 'x.y.z'。session.ensureBridge() 会读当前 bridge 版本,不一致时重注。共享 helpers 写在 bridges/common.js,通过 // @@include ./common.js 在注入前内联(不是运行时 require),所以所有 helpers 仍然是纯浏览器 JS。
bridge 注入后不注册事件监听器、定时器或 MutationObserver,只在 window.__jse_mp_*__ 上挂载当前版本 API。为避免页面上下文和浏览器扩展之间传递过大的对象,当前版本做了以下限制:
detectToken() / detectFingerprint() 按当前 URL 缓存结果;fallback 扫描 inline script 时逐个短路匹配,不再拼接全部脚本文本。fetchCgiBin() 优先按 JSON 解析响应;非 JSON 响应只返回短文本摘要,避免把完整 HTML/文本跨进程传出。total* / returned* 字段说明是否被截断。content-list --range/--from/--to 不再返回完整 XHR 原始响应,只返回 tendencySummary,完整趋势数据请使用 content-trend / content-sources 的结构化结果。v0.1 主要靠 DOM(表格 + KPI 卡)。v0.2+ 在 bridges/common.js::fetchCgiBin 里重放 /misc/appmsganalysis 的 action=get_article_stat_tendency_and_source 接口拿趋势/来源。DOM 读不到的数据走 XHR;可以读到就优先 DOM。
v0.4 规划阶段原本想给 detailpage 上 9 张 Highcharts 的数据走 XHR 重放,结论是端点数 = 0:
content-xhr-log 在 detailpage 完整加载 + 切 panel + 翻日期的全过程都没抓到任何额外的 appmsganalysis XHR(仅 get_article_stat_tendency_and_source 一个,已在 trend/sources 用)。window.Highcharts.charts 上(多版本 ESM bundle),从 JS 侧拿不到原始数据。<svg> 里的——所以 v0.4 改成对每张图直接读 SVG 中的 <text> 节点,做 Highcharts 11 anti-aliasing 伪重复去重(mirrored / pairwise 两道判别),按 kind(read-channel / share-channel / gender / age / read-time / finish-rate / follow-after / share-dest 等)做语义结构化。这样不依赖未声明的私有 XHR 端点,向前/向后兼容只受 SVG 类名 + 文本格式约束。
cd /Volumes/home_x/github/my/js-wechat-mp-ops-skill && npm installjs-eyes skills link /Volumes/home_x/github/my/js-wechat-mp-ops-skill
~/.js-eyes/config/config.json 的 extraSkillDirsskillsEnabled["js-wechat-mp-ops-skill"] = truejs-eyes skills reload(OpenClaw 插件 300ms 内热载)js-eyes skills list 应看到 Source: extra (/Volumes/home_x/github/my/js-wechat-mp-ops-skill)E_NO_TAB)js-eyes doctor 确认整体安全态卸载:js-eyes skills unlink /Volumes/home_x/github/my/js-wechat-mp-ops-skill
这些是 skill 在任何版本都不会做的事(DESTRUCTIVE 档位),避免后续补能力时跑偏:
fetchCgiBin 硬约束为 GET@js-eyes/skill-recording,给每次 tool 调用留调试记录navigateContentmsgid 维度;navigateContent 白名单校验 + front_type enum;download_summary_tendency 显式拒绝;新增内部踩点 CLI content-detail-dump / content-xhr-lognavigateUser INTERACTIVE 档位(切 attr / activity_analysis_page / clear 回增长,与 navigateContent 同模式,仅 location.assign);CLI 抽出 runNavigate 公共流程;新增通用业务脚本 scripts/batch-detail.js(批量拉单篇详情)、scripts/aggregate-content.js(聚合详情产报表)download_summary_tendency 加更显眼的黑名单提示| 现象 | 可能原因 | 处理 |
|---|---|---|
E_NO_TAB | 浏览器没打开对应分析页 | 在浏览器里打开 /misc/appmsganalysis 或 /misc/useranalysis |
RAW_EVAL_DISABLED | 一侧 allowRawEval=false | 宿主 config + 扩展 popup 都要开 |
not_logged_in | 登录态判据失败(URL token 缺失 / URL 在 login path / 无 weui-desktop-page_base) | 在浏览器里重新扫码登录 |
ready: false, reason: fans_lt_100 | 账号关注数 <100,后台未开放用户属性 | 后台原生限制,不是 bug |
ready: false, reason: wrong_subtab | 当前 URL 不在目标 action 子 tab | 按 hint 提示的 URL 切换 tab |
bridge 注入后仍 method_not_found | bridge VERSION 可能未 bump | 改 bridge 后 bump VERSION,CLI 会自动重注 |