Skip to content

Instantly share code, notes, and snippets.

@mucahit
Created May 7, 2018 00:17
Show Gist options
  • Save mucahit/186c237666768e189e29c2859f89b20f to your computer and use it in GitHub Desktop.
Save mucahit/186c237666768e189e29c2859f89b20f to your computer and use it in GitHub Desktop.
Share Link, Hashtag, Text or Username on Twitter using Javascript.
let base_url = "http://twitter.com/share?"; // Base url
// Params
const params = {
url: "http://google.com",
text: "Replace this with your text",
via: "sometwitterusername",
hashtags: "hashtag1,hashtag2"
};
for(const prop in params) base_url += `&${prop}=${encodeURIComponent(params[prop])}`;
window.open(base_url, '', 'left=0,top=0,width=550,height=450,personalbar=0,toolbar=0,scrollbars=0,resizable=0');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment