📰 Publish Article
Publish articles on X (requires Premium+). Simplified article creation and formatting.
📋 What It Does
This script provides the following capabilities:
- Automated operation — Runs directly in your browser console on x.com
- Configurable settings — Customize behavior via the CONFIG object
- Real-time progress — Shows live status updates with emoji-coded logs
- Rate limiting — Built-in delays to respect X/Twitter's rate limits
- Data export — Results exported as JSON/CSV for further analysis
Use cases:
- Publish articles on X (requires Premium+). Simplified article creation and formatting.
- Automate repetitive posting tasks on X/Twitter
- Save time with one-click automation — no API keys needed
- Works in any modern browser (Chrome, Firefox, Edge, Safari)
⚠️ Important Notes
Use responsibly! All automation should respect X/Twitter's Terms of Service. Use conservative settings and include breaks between sessions.
- This script runs in the browser DevTools console — not Node.js
- You must be logged in to x.com for the script to work
- Start with low limits and increase gradually
- Include random delays between actions to appear human
- Don't run multiple automation scripts simultaneously
🌐 Browser Console Usage
Steps:
- Go to
x.com/compose/article - Open browser console (
F12→ Console tab) - Copy and paste the script from
scripts/publishArticle.js - Press Enter to run
// scripts/publishArticle.js
// Browser console script for publishing articles on X/Twitter (Premium+)
// Paste in DevTools console on x.com/compose/article
// by nichxbt
(() => {
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
// =============================================
// CONFIGURE YOUR ARTICLE HERE
// =============================================
const ARTICLE = {
title: 'My Article Title',
body: `This is the body of my article.
You can write long-form content here with multiple paragraphs.
## Section Heading
Add sections, lists, and formatting:
- Point one
- Point two
- Point three
This requires Premium+ ($16/mo).`,
};
// =============================================
const SELECTORS = {
titleInput: '[data-testid="articleTitle"], [contenteditable][aria-label*="title" i], h1[contenteditable]',
bodyEditor: '[data-testid="articleBody"], [contenteditable][role="textbox"], [data-testid="richTextEditor"]',
publishButton: '[data-testid="articlePublish"], button[data-testid*="publish" i]',
saveDraft: '[data-testid="articleSaveDraft"], button[data-testid*="draft" i]',
};
const typeInElement = async (selector, text) => {
const el = document.querySelector(selector);
if (!el) {
console.log(`⚠️ Element not found: ${selector}`);
return false;
}
el.focus();
await sleep(200);
if (el.contentEditable === 'true') {
// For contenteditable elements
for (const char of text) {
if (char === '\n') {
document.execCommand('insertLineBreak', false);
} else {
document.execCommand('insertText', false, char);
}
await sleep(5);
}
} else {
// For input/textarea elements
for (const char of text) {
el.dispatchEvent(new InputEvent('beforeinput', { data: char, inputType: 'insertText', bubbles: true }));
document.execCommand('insertText', false, char);
await sleep(5);
}
}
return true;
};
const run = async () => {
console.log('📄 XActions Article Publisher');
console.log('============================');
if (!window.location.href.includes('compose/article') && !window.location.href.includes('articles')) {
console.log('⚠️ Navigate to x.com/compose/article first');
console.log(' (Requires Premium+ subscription)');
return;
}
// Enter title
console.log('📝 Entering title...');
const titleSuccess = await typeInElement(SELECTORS.titleInput, ARTICLE.title);
if (titleSuccess) {
console.log(` ✅ Title: "${ARTICLE.title}"`);
} else {
console.log(' ❌ Title input not found — may need Premium+');
return;
}
await sleep(1000);
// Enter body
console.log('📝 Entering body...');
const bodySuccess = await typeInElement(SELECTORS.bodyEditor, ARTICLE.body);
if (bodySuccess) {
console.log(` ✅ Body: ${ARTICLE.body.length} characters`);
}
await sleep(1000);
console.log('\n📄 Article ready to publish!');
console.log(' Click the publish button or run:');
console.log(' document.querySelector("[data-testid=articlePublish]")?.click()');
};
run();
})();
📖 Step-by-Step Tutorial
Step 1: Navigate to the right page
Open your browser and go to x.com/compose/article. Make sure you're logged in to your X/Twitter account.
Step 2: Open the browser console
- Chrome/Edge: Press
F12orCtrl+Shift+J(Mac:Cmd+Option+J) - Firefox: Press
F12orCtrl+Shift+K - Safari: Enable Developer menu in Preferences → Advanced, then press
Cmd+Option+C
Step 3: Paste the script
Copy the entire script from scripts/publishArticle.js and paste it into the console.
Step 4: Customize the CONFIG (optional)
Before running, you can modify the CONFIG object at the top of the script to adjust behavior:
const CONFIG = {
// Edit these values before running
// See Configuration table above for all options
};
Step 5: Run and monitor
Press Enter to run the script. Watch the console for real-time progress logs:
- ✅ Green messages = success
- 🔄 Blue messages = in progress
- ⚠️ Yellow messages = warnings
- ❌ Red messages = errors
Step 6: Export results
Most scripts automatically download results as JSON/CSV when complete. Check your Downloads folder.
🖥️ CLI Usage
You can also run this via the XActions CLI:
# Install XActions globally
npm install -g xactions
# Run via CLI
xactions --help
🤖 MCP Server Usage
Use with AI agents (Claude, Cursor, etc.) via the MCP server:
# Start MCP server
npm run mcp
See the MCP Setup Guide for integration with Claude Desktop, Cursor, and other AI tools.
📁 Source Files
| File | Description |
|---|---|
scripts/publishArticle.js |
Main script |
🔗 Related Scripts
| Script | Description |
|---|---|
| Article Publisher | Publish long-form articles on X/Twitter (requires Premium+ subscription) |
| Content Calendar | Plan and visualize your posting schedule |
| Content Repurposer | Transform your existing content: turn single tweets into threads, threads into singles, add hooks, rewrite for different audiences |
| Pin Tweet Manager | Pin and unpin tweets programmatically |
| Poll Creator | Create and manage poll tweets |
Author: nich (@nichxbt) — XActions on GitHub
⚡ Ready to try Publish Article?
XActions is 100% free and open-source. No API keys, no fees, no signup.
Browse All Scripts