Is there an easy way to open a Lemmy link from another instance?

I have an account on one server, but often browser from 9 other servers. Sometimes, I find a community I would like to follow. Is there an easy way to open that community from a different instance/server? I find searching for that community on my main server works, but is clumsy.

  • BeanCounter@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 years ago

    I have an account on one server, but often browser from 9 other servers.

    Do you literally open 9 tabs for each instances? If that’s the case, that’s kinda weird. You don’t have to. That’s the whole point of Lemmy.

    Link for a community in lemmy should be something like this: [Link Text](/c/communityName@instance.host). If you click that in whatever instance you’re in, you should be able to access the community in that instance.

    However, quite a lot of people just don’t care and copy/paste link for the community which is (understandable, but,) quite irritating. So after I read this post I just wrote this hacky Tampermonkey script to fix those links.

    // ==UserScript==
    // @name         Fix community link
    // @version      0.1
    // @match        https://[YOUR INSTANCE HERE]/post/*
    // @run-at       document-end
    // ==/UserScript==
    
    (function() {
        'use strict';
        const postLinks = document.getElementById("postContent").querySelectorAll("a:not(.community-link)");
        const comments = document.getElementsByClassName("comment-content");
    
        for (let aTag of postLinks) {
            const isCommunityLink = aTag.pathname.startsWith("/c/");
            aTag.href = isCommunityLink?aTag.pathname + "@" + aTag.host:aTag.href;
        };
        for (let comment of comments) {
            let commentLinks = comment.querySelectorAll("a:not(.community-link)");
            for (let aTag of commentLinks) {
                const isCommunityLink = aTag.pathname.startsWith("/c/");
                aTag.href = isCommunityLink?aTag.pathname + "@" + aTag.host:aTag.href;
            };
        };
    })();
    

    It’s very far from being pretty (I especially hate how isCommunityLink works) so let me know if there’s a better way I can do this!