The issue: You find a link to a neat lemmy community on some random instance. In order to subscribe, you have go to your instance, search for the community, find it, open it, subscribe…blah!
The fix: Use a simple browser bookmark to go to your home instance and open the federated community in one click.
This works through modifying the URL of the page your on and puts the host name (e.g. lemmy.ml) after an “@” symbol after the community and then changing the host name to your own, hard-coded one.
How to steps:
-
Create a bookmark in your browser and then “Edit” it.
-
Change the URL to this text (modify the “lemmy.world” bit with whatever your home instance is):
For lemmy.world users:
javascript:(function(){location.href="https://lemmy.world/c/"+location.href.match(/(?:.*)\/c\/(.*(?=\/)|.*$)/i)[1]+"@"+location.host.toString();})();
For lemmy.ml users:
javascript:(function(){location.href="https://lemmy.ml/c/"+location.href.match(/(?:.*)\/c\/(.*(?=\/)|.*$)/i)[1]+"@"+location.host.toString();})();
-
Change the name of the bookmark to whatever you want. Mine is named “lemmy.world”.
- You’re all set!
Now, from any federated community main feed page, click on the bookmark and you’ll magically be taken to the same community on your local instance. Magic!
Disclaimers: The community must be federated with your instance. You can only do this from a URL that has the community in url (e.g. not from a post or anything).
This sounds like a convoluted way… New Lemmy 0.18 does this automagically with /c/, ! and /u/.
However, not all instances are updating to 0.18, because it removes captcha.
However however, old instances can still work if you make a link like this:
[Link text](/c/community@instance)
or[Link text](/u/user@instance)
Like this: TWeaK or this: Lemmy
Frankly, I’d say making a link in the comments with /c/ or /u/ is much easier than creating a bookmark with a chunk of javascript. Plus, it creates a link others can use for themselves.
That only helps if you’re clicking the link from Lemmy itself. If you share or find a link some other way then it will be the full URL to a random instance still right?
Yeah, this script is more for links you find in the wild, not ones on Lemmy already.
Might not be super useful after better link handling is rolled out, but for now it’s been helpful for me.
Yeah and it’s a beautifully simple solution until then! Thank you for sharing