Skip to content

Instantly share code, notes, and snippets.

@onyx-nxt
Created June 1, 2026 02:18
Show Gist options
  • Select an option

  • Save onyx-nxt/eca6bfc76bd2e9d1e021ea25221e9613 to your computer and use it in GitHub Desktop.

Select an option

Save onyx-nxt/eca6bfc76bd2e9d1e021ea25221e9613 to your computer and use it in GitHub Desktop.
A user script fixing X's last update that made "Copy link" no longer the first item in the menu when clicking on sharing. Based on the chrome extension code from https://github.com/Blaasst/twitter-share-fixer
// ==UserScript==
// @name X share fixer
// @namespace https://github.com/Blaasst/twitter-share-fixer
// @version 2026-06-01
// @description A user script fixing X's last update that made "Copy link" no longer the first item in the menu when clicking on sharing. Based on the chrome extension code from https://github.com/Blaasst/twitter-share-fixer
// @author Blaasst
// @match https://x.com/*
// @match https://twitter.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=x.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
let observer;
function fixShareMenu() {
const menu = document.querySelector('[role="menu"]');
if (!menu) return;
const items = Array.from(menu.querySelectorAll('[role="menuitem"]'));
if (items.length < 2) return;
const chatItem = items.find(item => item.textContent.includes('Send via Chat') || item.textContent.includes('Envoyer via un Message Privé'));
const linkItem = items.find(item => item.textContent.includes('Copy link') || item.textContent.includes('Copier le lien'));
if (chatItem && linkItem) {
if (observer) observer.disconnect();
if (menu.style.display !== 'flex') {
menu.style.display = 'flex';
menu.style.flexDirection = 'column';
}
linkItem.style.order = '1';
chatItem.style.order = '2';
items.forEach(item => {
if (item !== chatItem && item !== linkItem) {
item.style.order = '3';
}
});
startObserver();
}
}
function startObserver() {
observer.observe(document.body, { childList: true, subtree: true });
}
observer = new MutationObserver(() => fixShareMenu());
startObserver();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment