Skip to content

Instantly share code, notes, and snippets.

@mogita
Created May 24, 2024 10:18
Show Gist options
  • Save mogita/d544213732a1f8eac380fbda7203e998 to your computer and use it in GitHub Desktop.
Save mogita/d544213732a1f8eac380fbda7203e998 to your computer and use it in GitHub Desktop.
Share to mastodon bookmarklet with commet placeholder
// Usage:
// - copy the minified line of code
// - replace the mastodon domain name near the end of the code with your instance
// - create a new bookmark in your browser and paste the whole code to the URL input box
// - click on the bookmark to share the current page
// - (optional) feel free to tweak the format of the shared text if you know some JavaScript
// minified
javascript:void((function(w,d,e,i){s=w.getSelection().toString();t=e(s?s+"\n\n":"");w.open(`https://${i}/share?text=${t}${e(d.title)}${e(" ")}${e(d.URL)}${e("\n\n// ")}`,'_blank')}(window,document,encodeURIComponent,'mastodon.social')));
// beautified
javascript: void((function(w, d, e, i) {
s = w.getSelection().toString();
t = e(s ? s + "\n\n" : "");
w.open(`https://${i}/share?text=${t}${e(d.title)}${e(" ")}${e(d.URL)}${e("\n\n// ")}`, '_blank')
}(window, document, encodeURIComponent, 'mastodon.social')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment