Skip to content

Instantly share code, notes, and snippets.

@risent
Last active May 30, 2018 02:45
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 risent/cf4eb684ed21ad9ef62ffaa1d3b01993 to your computer and use it in GitHub Desktop.
Save risent/cf4eb684ed21ad9ef62ffaa1d3b01993 to your computer and use it in GitHub Desktop.
Twitter Shared Button Bookmarlet
fcuntion() {
var text = encodeURIComponent(window.getSelection().toString() || window.document.title);
var url = encodeURIComponent(window.location.href);
var dstUrl = 'https://twitter.com/intent/tweet?url=' + url + '&text=' + text;
var windowName = 'Tweet Intent';
var features = 'width=600,height=350,left=600,top=200';
window.open(dstUrl, windowName, features);
};
javascript:(function()%7Bwindow.twitter%20%3D%20window.twitter%20%7C%7C%20%7B%7D%3Bvar%20text%20%3D%20encodeURIComponent(window.getSelection().toString()%20%7C%7C%20window.document.title)%3Bvar%20url%20%3D%20encodeURIComponent(window.location.href)%3Bvar%20dstUrl%20%3D%20'https%3A%2F%2Ftwitter.com%2Fintent%2Ftweet%3Furl%3D'%20%2B%20url%20%2B%20%20%20'%26text%3D'%20%2B%20text%3Bvar%20windowName%20%3D%20'Tweet%20Intent'%3Bvar%20features%20%3D%20'width%3D600%2Cheight%3D350%2Cleft%3D600%2Ctop%3D200'%3Bwindow.open(dstUrl%2C%20windowName%2C%20features)%7D)()
@risent
Copy link
Author

risent commented May 30, 2018

Tweet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment