Skip to content

Instantly share code, notes, and snippets.

@kentbrew
Last active March 14, 2023 01:10
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kentbrew/e7def09068834d9d1415824befa8d2dc to your computer and use it in GitHub Desktop.
Save kentbrew/e7def09068834d9d1415824befa8d2dc to your computer and use it in GitHub Desktop.
Tootski, a sharing bookmarklet for Mastodon

Tootski, a sharing bookmarklet for Mastodon

Kent Brewster

Tootski is a bookmarklet that will share the page you're on to your Mastodon instance, including the title, address, and any text you may have selected. If you have any questions or need help, please find me at https://xoxo.zone/@kentbrew.

Before You Begin

You need to know the name of your Mastodon instance if it's not mastodon.social. To find it, visit your home page on Mastodon and copy out the part between the second and third slash. My home URL looks like this:

https://xoxo.zone/@kentbrew

... so the name I need is xoxo.zone. Note: I'm going to be careful here to only copy over the name, not the https:// part or any slashes!

Desktop Browsers

For Firefox, Chrome, Edge, Opera, and Everybody Else Except Safari

Right-click your bookmarks bar and choose New Bookmarklet (Firefox) or Add Page (Chrome, Edge, Opera)

In Name, put this:

Tootski

In URL, put this:

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("\n\n")}${e(d.URL)}`,'_blank')}(window,document,encodeURIComponent,'mastodon.social')));

Before you save, be sure to change where it says mastodon.social at the end of the JavaScript to the name of your instance. You may need to scroll right to see it; it's at the very end.

For My Little Special Friend Safari:

  • if you don't see your bookmarks bar, choose Show Favorites Bar under View, main menu
  • open about:blank in a new window (otherwise your new bookmarklet will have the favicon of whatever page you're on right now)
  • hit command-D to start a new bookmarklet
  • choose Favorites under Add this page to:
  • enter Tootski in the Name box and click Add; a new bookmarklet should appear
  • right-click your new bookmarklet and choose Edit Address
  • paste in the JavaScript from above, with the instance name fixed up.

Mobile Devices

For Safari On iPhone and iPadOS: I am reliably informed that this works on iPadOS in Safari. I'm not sure how my correspondent did the install; will confirm when I find out. If your various Safaris are synched, your desktop bookmarklet might automagically show up on your iPhone. If it doesn't:

  • Visit this page.
  • Tap the Share icon
  • Tap Add Bookmark
  • Edit the title to say Tootski
  • Tap Done
  • Tap the Bookmarks icon
  • Tap Favorites
  • Press and hold your Tootski bookmarklet
  • Tap Edit
  • Paste the JavaScript
  • Fix the instance name
  • Tap Done

It also looks like a Shortcut might do the trick. You probably want to use their builder and not drop in this hunk of JavaScript and try not to run their Scripting module, which requires opening up some scary-looking permissions. Please let me know if you get one working. It would also be great to learn how to deep-link directly into the Mastodon mobile app.

For your device (IOS or Android) running mobile Chrome:

  • Get to this page in your Android browser.
  • Copy the Javascript snippet.
  • Tap the three-dot overflow menu next to the URL bar (it might be at the bottom of the page)
  • Tap Add to Bookmarks
  • Tap Edit
  • Paste in the code.
  • Fix up the instance name.
  • Save. When you're ready to toot a page, bring up Bookmarks, then Mobile Bookmarks, then tap Tootski.

Thank You

@mediajunkie
Copy link

mediajunkie commented Dec 25, 2022

aw, man! it is easy to inspire a brilliant craftsperson when all it takes is just asking for cool stuff!

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