Skip to content

Instantly share code, notes, and snippets.

@hkitago
Last active May 8, 2024 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hkitago/67ed3a91c7941ab9a2c6b657bac692cb to your computer and use it in GitHub Desktop.
Save hkitago/67ed3a91c7941ab9a2c6b657bac692cb to your computer and use it in GitHub Desktop.
Bookmarklet to create a new post for X with a text selected and the URL.
javascript:(()=>{w=window,d=document,t=(w.getSelection?w.getSelection():d.getSelection?d.getSelection():d.selection.createRange().text);if(!t||t==''){void(t=prompt('Create new XPost:',''));if(!t){t=d.title;}}else{t=`"${t}"`}if(t){w.open(`https://x.com/intent/tweet?text=${encodeURIComponent(t+' '+location.href)}`)}})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment