展示 HN:X Writer – 在 VS Code 中无干扰地发推文(自带密钥,开源)
Show HN: X Writer – VS Code extension to post tweets from your editor

原始链接: https://github.com/Jawuilp/X-writer

## X Writer:直接从 VS Code 发推 X Writer 是一个 VS Code 扩展,允许您无需离开编辑器即可直接发布到 Twitter/X。它优先考虑用户控制,采用“自带密钥”(BYOK)系统,要求您提供自己的 API 密钥和令牌以增强安全性——通过 VS Code 的安全 SecretStorage 存储。 主要功能包括:通过活动栏或上下文菜单(右键单击选定的代码)快速发布,实时字符计数器(最多 280 个字符),已发布推文的直接链接,以及对英语和西班牙语的支持。 该扩展会自动跟踪并强制执行 Twitter/X 的免费 API 限制,即每天 17 条推文。设置过程包括从 Twitter 开发者门户获取密钥并在 VS Code 中进行配置。开发很简单,使用 `pnpm install` 即可,并内置了监视模式。

## X Writer:直接从 VS Code 发推 一款名为“X Writer”的全新 VS Code 扩展(由 jawuilp 构建,可在 VS Code Marketplace 和 GitHub 上获取),旨在通过允许直接从编辑器发推来提高开发人员的生产力——消除令人分心的浏览器上下文切换。 该扩展是针对现有扩展在 X API v2 变更后出现的问题而创建的,优先考虑隐私并遵守免费 API 限制(24 小时 17 条推文)。它采用“自带密钥”(BYOK)系统,安全地将 API 凭据存储在本地,并提供只写功能以保持专注。 这个开源项目是作者的第一个扩展,他们欢迎对代码结构提出反馈。它专为参与 #BuildInPublic 等运动的开发者设计,旨在提供一种简化的分享更新方式,避免陷入“无休止浏览”的陷阱。
相关文章

原文

VS Code extension to post tweets to Twitter/X directly from your editor.

  • 🔐 BYOK (Bring Your Own Keys): Your credentials, your total control.
  • ✍️ Fast Posting: Post tweets without leaving VS Code.
  • 🎯 Smart Context: Select code → Right Click → Automatic Tweet.
  • 🛡️ Limit Protection: Automatic counter (17 tweets/day).
  • 📊 Real-time Counter: Visualize characters while you type.
  • 🔗 Direct Links: Open your published tweets with one click.
  • 💙 Activity Bar: Custom icon in the sidebar.
  • 🚀 Modern Interface: Custom view with quick actions.
  • 🌍 Internationalization: Support for English and Spanish.

Installation & Development

  1. Clone this repository.
  2. Run pnpm install to install dependencies.
  3. Press F5 to open a VS Code development window.

This project uses esbuild for bundling.

  • Development Watch Mode: npm run watch
  • Build for Production: npm run compile
  • Package Extension (.vsix): pnpm run package
  1. Go to Twitter Developer Portal.
  2. Create an app (or use an existing one).
  3. Generate your API Keys and Access Tokens.
  4. You will need:
    • API Key
    • API Secret
    • Access Token
    • Access Secret
  1. Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
  2. Search for: X Writer: Setup Credentials.
  3. Choose an option:
    • Import from file (Recommended): Select a .env or .txt file with your keys (API_KEY=...).
    • Enter manually: Copy and paste your 4 keys one by one.

Note: Make sure to regenerate your Access Tokens after changing the App Permissions to "Read and Write" in the developer portal.

If you like the extension, you can support me by buying me a coffee ☕:

ko-fi

Method 1: From Activity Bar

  1. Click on the X Writer icon in the left sidebar 🐦.
  2. Click on "✍️ Post Tweet".
  3. Write your message (real-time counter: X/280).
  4. Done! You will see a "View on X" button to open it in the browser.

Method 2: With Smart Context

  1. Select code or text in the editor.
  2. Ctrl+Shift+PX Writer: Post Tweet.
  3. The selected text will pre-fill automatically.
  4. Edit and publish.

Method 3: From Commands

  1. Open the Command Palette (Ctrl+Shift+P).
  2. Search for: X Writer: Post Tweet.
  3. Write your message.
  4. Done!

⚠️ Respecting the X Free API limits:

  • 17 tweets per day (automatic counter).
  • The limit resets every 24 hours.
  • You will see remaining tweets on every post.
  1. Open the Command Palette.
  2. Search for: X Writer: Reset Credentials.

Credentials are stored securely using VS Code's SecretStorage API, which utilizes the operating system's credential system (Keychain on macOS, Credential Manager on Windows, Secret Service on Linux).

  • Click on the "❓ Help & About" icon in the sidebar to see commands and developer info.
  • Change Language: Settings > X Writer > Language.

MIT

联系我们 contact @ memedata.com