DEV Community

Haoyang Pang
Haoyang Pang

Posted on

I Open-Sourced Claude Code Skills for Reddit and DEV.to Automation (AppleScript + Chrome)

Every browser automation tool — Playwright, Selenium, Puppeteer — sets navigator.webdriver=true. Reddit detects it instantly. DEV.to's React editor fights back against programmatic input. I needed a different approach.

Turns out macOS has had the answer all along: AppleScript can execute JavaScript inside your real Chrome browser. Same cookies, same fingerprint, same everything. Sites literally cannot tell the difference between you and the script.

I built two Claude Code skill packages around this technique and open-sourced them.

The Skills

1. Reddit Automation (claude-skill-reddit)

Two skills in one repo:

reddit-cultivate — Automated karma building

  • Scans rising posts across target subreddits via /r/{sub}/rising.json
  • Drafts natural, value-first comments
  • Posts via Reddit's internal /api/comment endpoint
  • Outputs a summary table with direct links to every comment

reddit-post — Submit posts to any subreddit

  • Text posts or link posts via /api/submit
  • Automatic modhash (CSRF) handling
  • Flair detection and application
  • Spam filter avoidance guidelines

2. DEV.to Publishing (claude-skill-devto)

devto-post — Publish articles via CSRF API

  • Bypasses DEV.to's buggy React editor entirely
  • Uses POST /articles with X-CSRF-Token
  • Single API call = article published
  • Handles long articles via temp file + JXA injection

The Core Technique

# Execute JavaScript in Chrome's active tab
osascript -e 'tell application "Google Chrome" to tell active tab of first window to execute javascript "fetch(\"/api/me.json\").then(r=>r.json()).then(d=>{document.title=JSON.stringify(d)})"'

# Read async result back via document.title
sleep 2
osascript -e 'tell application "Google Chrome" to return title of active tab of first window'
Enter fullscreen mode Exit fullscreen mode

The document.title trick is key — since AppleScript can't directly await async JS, we write results to the page title and read it back.

For complex JavaScript (avoiding escaping hell), use JXA:

osascript -l JavaScript -e '
var chrome = Application("Google Chrome");
var tab = chrome.windows[0].activeTab;
tab.execute({javascript: "(" + function() {
    // Any JS here — no escaping needed
    fetch("/api/endpoint", {credentials: "include"})
        .then(r => r.json())
        .then(d => { document.title = JSON.stringify(d); });
} + ")();"});
'
Enter fullscreen mode Exit fullscreen mode

Why Not Just Use the APIs Directly?

  • Reddit API requires OAuth app registration and gets rate-limited/IP-blocked fast
  • DEV.to editor has React state bugs (tags concatenate, auto-save drafts persist bad state)
  • AppleScript + Chrome uses your existing login session — no tokens, no registration, no detection

Install

npx skills add PHY041/claude-skill-reddit
npx skills add PHY041/claude-skill-devto
Enter fullscreen mode Exit fullscreen mode

Or clone directly:

Requirements: macOS + Chrome with "Allow JavaScript from Apple Events" enabled (Chrome → View → Developer → toggle it on, then restart Chrome).

What I Learned Building These

  1. The document.title trick is universal — works for any async operation on any site
  2. JXA > AppleScript for complex JS — no escaping, template literals work
  3. DEV.to's CSRF API is way more reliable than the editor — one POST call vs fighting React state
  4. Reddit's internal API is the same one their frontend uses — same-origin fetch with cookies just works
  5. Chrome multi-profile can break AppleScript — always check count of windows first and fall back to System Events + Console keyboard automation

These skills are the real deal — I use them daily for my own Reddit cultivation and blog publishing. Feedback and PRs welcome!

Top comments (0)