Skip to content

Instantly share code, notes, and snippets.

@eyssette
Last active November 18, 2022 23:34
Show Gist options
  • Save eyssette/a3c0df2a52b43ca1e2c78299b97c6306 to your computer and use it in GitHub Desktop.
Save eyssette/a3c0df2a52b43ca1e2c78299b97c6306 to your computer and use it in GitHub Desktop.
A bookmarklet to copy Mastodon account info to clipboard
  1. Copy the code below:
javascript:var name=document.querySelector(".account__header__tabs__name").firstChild.firstChild.innerText; var mastodonAccount=document.querySelector(".account__header__tabs__name").firstChild.children[1].innerText; var mastodonURL=mastodonAccount.split('@'); navigator.clipboard.writeText(mastodonAccount+','+name+','+'https://'+mastodonURL[2]+'/@'+mastodonURL[1]);
  1. Create a new bookmark.
  2. Set the bookmarklet name and paste the above as the URL.
@trutzig89182
Copy link

Hey, I tried it but couldn’t get it to work. What browser do you use? And can you describe a bit more in detail what to do?

@eyssette
Copy link
Author

I'm using Brave, but it also works on Chrome and Firefox.
You need to be in advanced view. Click on a profile to have it displayed on the right. Then click on the bookmarklet.
Sorry my instructions were not clear enough.
Is it working now?

@trutzig89182
Copy link

Nice, yes. There’s a but, though. Mastodon 4. switches where the profile picture leads. If I see it correctly, the url was generated via the link included in the profile picture. But with Mastodon 4 clicking the preview image will extend the image and not lead to the profile on the home sever. I tested it with social.tchncs.de (which is on M4) and fediscience.org (which is on M3). Did work with fediscience smoothly, but in social.tchncs it returns the profile picture url.

@eyssette
Copy link
Author

I've already updated the code. You should copy the new version. It works on M4.

javascript:var name=document.querySelector(".account__header__tabs__name").firstChild.firstChild.innerText; var mastodonAccount=document.querySelector(".account__header__tabs__name").firstChild.children[1].innerText; var mastodonURL=mastodonAccount.split('@'); navigator.clipboard.writeText(mastodonAccount+','+name+','+'https://'+mastodonURL[2]+'/@'+mastodonURL[1]);

@trutzig89182
Copy link

Ah, sorry, had the old bookmark set. Works now for me and also when I am not in advanced view!

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