cross-posted from: https://lemmy.world/post/530489
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).
Thanks, this is great! Could this be expanded so that it works with kbin too?
Sure, just replace
/c/
with/m/
after your kbin instance.For kbin.social it would be:
javascript:(function(){location.href="https://kbin.social/m/"+location.href.match(/(?:.*)\/c\/(.*(?=\/)|.*$)/i)[1]+"@"+location.host.toString();})();
This seems to work
javascript:(function(){location.href=("https://EXAMPLE.COM/c/"+location.href.match(/(?:.*)\/[cm]\/(.*(?=\/)|.*$)/i)[1]+"@"+location.host.toString()).replace(/(@.+)@.*/, "$1");})();
Sorry, I meant that I can search for a kbin community on lemmy. I almost have it figured out [mc] instead of c in the href.match. kbin just uses e.g. https://kbin.social/m/canada@lemmy.ca as url, and the search ends up being @lemmy.ca@kbin.social, the second domain would need to be removed. It is added by +“@”+location.host.toString()
deleted by creator