BeanCounter,

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/[email protected]). 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.


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

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!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • [email protected]
  • aaaaaaacccccccce
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • oklahoma
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • SuperSentai
  • feritale
  • KamenRider
  • All magazines