Post

X (Twitter) Tweet & Article Copy Userscript: Bypassing t.co Shortlinks

🇬🇧 A Tampermonkey userscript that allows you to copy tweets and long articles on X (Twitter) directly to your clipboard in both Markdown and HTML format while automatically resolving shortened t.co links in the background.

X (Twitter) Tweet & Article Copy Userscript: Bypassing t.co Shortlinks

When browsing X (formerly Twitter), copying a useful thread or a long article into your note-taking apps can sometimes be a hassle due to the platform’s UI structure. An even bigger issue is link clutter: All external links in the content you copy are forced into the platform’s own tracking and redirection service, t.co.

To make this process as smooth as possible, the Tampermonkey Tweet Copy userscript has been developed, building upon tizee’s original concept and enhancing it with new features. | 🇹🇷 Türkçe

Why Do You Need This Script?

Instead of manually selecting and copying content on X, the extension adds a sleek “Copy” icon next to the standard action buttons. When clicked, it handles the following tasks behind the scenes in seconds:

  1. Extracts Content Flawlessly: Accurately parses the title, body text, and media text of the selected Tweet or X Article.
  2. Resolves t.co Shortlinks: The biggest innovation of the extension; it asynchronously and in parallel scans and resolves shortened t.co links within the text (supporting 301, 302, and Meta Refresh redirects) to find their original destinations. Your clipboard will contain actual, unmasked URLs instead of ambiguous t.co links.
  3. Rich Clipboard Support (Dual-Format): It copies the content in both raw Markdown text and rich HTML format. This ensures that when you paste it into tools like Notion, Obsidian, or Word, the structural layout remains intact.
  4. Hashtag and Mention Preservation: Elements that are visually clickable but do not actually contain external links, such as #hashtags or @usernames, are preserved as plain text without being converted into unnecessary links.

How to Install and Use

The extension works seamlessly with any popular userscript manager like Tampermonkey or Violentmonkey.

  1. Make sure you have the Tampermonkey extension installed in your browser.
  2. Click to install the script directly from GreasyFork: Install from GreasyFork
  3. Or, if you prefer, you can install the raw code directly from the GitHub repository: Install from GitHub

Usage Steps

After installation, whenever a tweet or article is displayed on X (https://x.com/), a new copy icon will appear next to the like/retweet icons (action bar).

  • Upon clicking the icon, you will briefly see an hourglass (⏳) animation while t.co redirects are being resolved.
  • Once the whole process is complete in just a few milliseconds, a green check mark (✅) animation will appear, indicating that the operation was completely successful.
  • Now you can paste the content anywhere you want, just as clean as the original author wrote it!

Customization and Technical Background

The script uses standard CSS rules for the visual feedback animations (⏳ and ✅) injected into the interface. If you wish to change the colors, transition durations, or positioning to suit your taste, you can freely edit the GM_addStyle code snippet at the top of the script within Tampermonkey.

The entire project is open-source and distributed under the MIT license. If you’d like to inspect the code, contribute (via Pull Request), or support the project with a star, you can visit the repository page:

Source Code and GitHub Repository: fr0stb1rd/tampermonkey-tweet-copy

This post is licensed under CC BY 4.0 by the author.