关于 reddit-post
这项 Skill 通过 AppleScript 控制用户已登录的 macOS Chrome,向 Reddit 发布文本或链接帖子,并提供版块选择、添加 Flair 与故障排查指引。
主要功能
- 01发布文本帖和链接帖
- 02通过 AppleScript 控制 Chrome
- 03获取帖子链接并添加 Flair
- 04版块选择与发布时间建议
- 05垃圾信息过滤及错误排查
适用场景
- 01在 Reddit 发布项目公告
- 02向相关版块分享工具
- 03发布后添加必需的 Flair
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ phy041/ claude-skill-reddit --skill reddit-post安装后在 Claude Code 中输入/reddit-post确认已加载。
详细介绍
Reddit 发布技能(AppleScript Chrome 控制)
通过 AppleScript 控制用户真实的 Chrome,在 Reddit 上发帖。无需 Playwright、无需 Selenium、无需 API 令牌。
工作原理
Claude Code → osascript → Chrome (real browser, logged in) → Reddit /api/submit
- 使用 Cookie 进行同源 fetch → 无法检测
- Reddit 的
/api/submit端点用于发布文本帖/链接帖 - 从
/api/me.json获取 Modhash,用于 CSRF 保护
前置条件
- 仅限 macOS(AppleScript 是 macOS 技术)
- Chrome:查看 → 开发者 → 允许来自 Apple Events 的 JavaScript(启用后重启 Chrome)
- 用户已在 Chrome 中登录 Reddit
方法检测(先运行)
WINDOWS=$(osascript -e 'tell application "Google Chrome" to return count of windows' 2>/dev/null)
if [ "$WINDOWS" = "0" ] || [ -z "$WINDOWS" ]; then
echo "METHOD 2 (System Events + Console)"
else
echo "METHOD 1 (execute javascript)"
fi
完整的方式 1 与方式 2 详情请参阅 reddit-cultivate 技能。
发布工作流
步骤 1:获取 Modhash
osascript -e 'tell application "Google Chrome" to tell active tab of first window to execute javascript "fetch(\"/api/me.json\",{credentials:\"include\"}).then(r=>r.json()).then(d=>{document.title=\"UH:\"+d.data.modhash})"'
sleep 2
osascript -e 'tell application "Google Chrome" to return title of active tab of first window'
步骤 2:提交帖子
先将 Chrome 导航至 reddit.com(同源要求),然后提交:
(async()=>{
try {
let body = new URLSearchParams({
sr: "SideProject", // subreddit name (no r/ prefix)
kind: "self", // "self" for text, "link" for URL
title: "Your post title",
text: "Your post body with **markdown** support",
uh: "MODHASH_HERE",
api_type: "json",
resubmit: "true"
});
let resp = await fetch("/api/submit", {
method: "POST",
credentials: "include",
headers: {"Content-Type": "application/x-www-form-urlencoded"},
body: body.toString()
});
let result = await resp.json();
document.title = "POSTED:" + JSON.stringify(result);
} catch(e) {
document.title = "ERR:" + e.message;
}
})()
对于链接帖,请更改:
kind: "link",
url: "https://github.com/your/repo", // instead of text
步骤 3:提取帖子链接
响应中包含 result.json.data.url——指向新帖的直接链接。
步骤 4:添加 Flair(如有要求)
某些 subreddit 要求添加 flair。发帖后,使用:
(async()=>{
try {
// First get available flairs
let resp = await fetch("/r/SUBREDDIT/api/link_flair_v2", {credentials: "include"});
let flairs = await resp.json();
document.title = "FLAIRS:" + JSON.stringify(flairs.map(f => ({id: f.id, text: f.text})));
} catch(e) {
document.title = "ERR:" + e.message;
}
})()
然后应用 flair:
(async()=>{
try {
let body = new URLSearchParams({
link: "t3_POST_ID",
flair_template_id: "FLAIR_ID",
uh: "MODHASH"
});
await fetch("/api/selectflair", {
method: "POST",
credentials: "include",
headers: {"Content-Type": "application/x-www-form-urlencoded"},
body: body.toString()
});
document.title = "FLAIR_SET";
} catch(e) {
document.title = "ERR:" + e.message;
}
})()
步骤 5:会话摘要
结尾务必附上帖子链接:
| Sub | 标题 | 帖子链接 |
|---|---|---|
| r/SideProject | "你的标题" | https://www.reddit.com/r/SideProject/comments/abc123/... |
避免垃圾信息过滤器
标题/正文中应避免的词语
| 避免使用 | 改用 |
|---|---|
| crawl、crawled、crawling | compiled、cataloged、indexed、collected |
| scrape、scraping | gathered、extracted、retrieved |
| bot、automated | 工具、脚本、程序 |
| free(过度使用) | 开源、MIT 许可 |
| hack、hacks | 提示、技巧、方法 |
应避免触发的内容
- 多个外部链接(最多 1-2 个)
- URL 缩短服务(bit.ly、tinyurl)
- 新账号 + 推广内容
- 短时间内在多个 subreddit 发布相同内容
- 过度使用自我推广措辞
开源项目的最佳 Subreddit
| Subreddit | 成员数 | 最适合 | 备注 |
|---|---|---|---|
| r/coolgithubprojects | 60K | GitHub 仓库 | 专为此类内容而设! |
| r/SideProject | 453K | 副项目 | 非常友好 |
| r/opensource | 100K+ | 开源工具 | 技术受众 |
| r/programming | 6M+ | 开发工具 | 竞争激烈 |
| r/Python | 1.5M+ | Python 工具 | 社区活跃 |
| r/webdev | 2M+ | Web 工具 | 仅限“Showoff Saturday” |
| r/selfhosted | 400K+ | 可自托管工具 | 互动效果很好 |
最佳发帖时间(美国东部时间)
| 星期 | 最佳时间 |
|---|---|
| 星期一 | 6-8 AM |
| 星期二 | 7-9 AM |
| 星期三 | 8-10 AM |
| 星期四 | 7-9 AM |
| 星期五 | 6-8 AM |
| 星期六 | 7-9 AM |
| 星期日 | 8-10 AM |
在高峰时段前 30 分钟发帖,以积累热度。
帖子模板
开源项目公告
Title: I built [PROJECT_NAME] - [one-line description] (open source)
Body:
Hey everyone,
I created [PROJECT_NAME] to solve [PROBLEM].
**What it does:**
- Feature 1
- Feature 2
- Feature 3
**Tech stack:** [Languages/frameworks]
**Links:**
- GitHub: [single link]
Happy to answer any questions!
工具/资源分享
Title: [TOOL_NAME]: [what it does] - free and open source
Body:
Built this because [reason/pain point].
**Features:**
- [List 3-5 key features]
**How to use:**
[Brief code example or instructions]
GitHub: [link]
Feedback welcome!
跨版发布策略
在不同 subreddit 错开发帖,以扩大覆盖范围:
- 第 1 天:主要 subreddit(最相关)
- 第 2-3 天:次要 subreddit(受众不同)
- 第 4-5 天:综合 subreddit(r/SideProject 等)
切勿在同一天向多个 subreddit 发帖——这会触发垃圾信息检测。
错误恢复
| 问题 | 解决方案 |
|---|---|
| “帖子被过滤器移除” | 改写内容,避免触发词并减少链接 |
| “你操作得太频繁了” | 等待 10-15 分钟;需要更多 karma |
| “此社区要求添加 flair” | 发帖后使用 /api/selectflair |
| “标题太长” | 控制在 300 个字符以内 |
| 帖子不可见 | 检查是否被 shadowban:在无痕模式下查看个人资料 |
| Modhash 已过期 | 从 /api/me.json 重新获取 |
为什么使用 AppleScript(而不是 Playwright)
| 工具 | 问题 |
|---|---|
| Playwright | navigator.webdriver=true,会被 Reddit 检测到 |
| Selenium | 同样存在检测问题 |
| curl + API | 请求几次后 IP 会被封锁 |
| AppleScript | 控制真实的 Chrome,无法检测到,并包含 Cookie |
评论
支持 Markdown