If you didn’t already know about it, I included the full description after the release notes.

Release 1.3.0

  • You can now add multiple secondary instances: so if you, like me, also have an account on lemmynsfw.com (or of course any other instance), you can add that there and not have links rewritten for that instance
  • You can manually enter your home instance. Useful for self-hosted instances that didn’t show up in my instance list.

Full Description Below:

Description

Lemmy Universal Link Switcher, or LULs for short, scans all links on all websites, and if any link points to a Lemmy instance that is not your main/home instance, it rewrites the link so that it instead points to your main instance.

Also works on Firefox Android with the Tampermonkey extension!

Features

  • Rewrite links to Lemmy posts/comments to point to your home instance. Only after hovering over them, because getting home posts/comments links require communicating with the Lemmy servers, and we don’t want to spam the servers.

  • Instantly rewrite all links of community or user links to Lemmy/kbin on all websites everywhere to your new instance! The rewritten links will have an icon next to it, and hovering/touching the icon will show you the original link, allowing you to go there if you want to.
    community links being rewritten

  • If you are already on a page that has a corresponding page on your home instance, a link will automatically be added to the page header.
    the header link to your home instance when already on a remote post

Home Instance Setup

Simply visit the Lemmy instance you want to set as your home while the script is active. You will be asked if you want to set this instance to your home instance:
popup to select home instance

Settings

If you want to change your home instance or add secondary instances in case you have multiple accounts, simply go to the script settings, accessible within Violent/Tampermonkey directly, or alternatively within any Lemmy instances’ settings.
button to set your new home instance

Common Issues

Coming soon

  • Rewrite kbin post/comment links
  • Better rewriting support for kbin community/user urls (e.g. sort options are currently ignored)
  • Nicer tooltip styling (fit into page theme)
  • Signify that “Show at home” button is loading for posts/comments
  • Integrate with lmmy.to redirector
  • Deez@lemm.ee
    link
    fedilink
    English
    arrow-up
    7
    ·
    1 year ago

    That’s awesome, thanks for sharing!

    Does anyone know of any web tools or Shortcuts that can do the same thing on iOS?

    • Azzu@lemm.eeOP
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      1 year ago

      You can install userscripts on Safari on iOS. Dunno though if it actually works. That’s the cool thing about user scripts, they work basically anywhere if you want to.

      • Deez@lemm.ee
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Oh I didn’t know that! I installed Userscripts and the script, but haven’t been able to get it to work yet though…

        Anyone else get it working?

        • Azzu@lemm.eeOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 year ago

          If you can get any error message posted or sth I might be able to fix it, but I’ve got no way to test it on any apple device, that’s a bit of a problem :D

          • Deez@lemm.ee
            link
            fedilink
            English
            arrow-up
            2
            ·
            1 year ago

            Thanks! Sorry my “it’s not working” wasn’t very helpful, and unfortunately I don’t have any error messages. Here’s what I can see:

            • Userscripts has full access to all sites through Settings > Safari > Extensions.
            • Userscripts appears as an extension in Safari
            • LULs script was added to the Userscripts directory and is enabled in the Userscripts Safari Extension
            • When I first browsed to my home Lemmy instance I was prompted to set it as the home instance through a pop up message (indicating to me that the script is at least partially working)
            • The rewritten icon does not appear next to any links on foreign instances
            • Clicking on the links does not take me to my home instance, they just stay on the foreign instance
            • The “Show on <home instance>” link does not appear on foreign communities
            • “Lemmy Universal Link Switcher Settings” link does not appear in my home instance settings
            • There doesn’t seem to be a way to open script settings in Userscripts on iOS like is shown in the Violentmonkey screenshot on the documentation
            • In summary, it doesn’t look like LULs is making any changes to any Lemmy instances in Safari.

            Things I tried which had no effect:

            • Turning off local and network ad-blockers
            • Restarting the iPad
            • Disabling and re-enabling Userscripts extension
            • Deleting and reinstalling the LULs script - I noted that I wasn’t prompted to setup my instance again so maybe that was cached somewhere else?
            • Clearing Safari cache (and was still not prompted to set home instance again)

            Violentmonkey and Tampermonkey did not seem to have iOS clients, but for troubleshooting purposes I installed the Gear browser app. I understand Gear has it’s own browser engine and supports userscripts directly. After installing the LULs the script worked when browsing in Gear.

            I’m not likely to switch from Safari to Gear for browsing, so ideally it would be great to get it working in Safari.

            Are there any other troubleshooting steps or settings in Safari you could suggest to get it working?

            • Azzu@lemm.eeOP
              link
              fedilink
              English
              arrow-up
              1
              ·
              1 year ago

              The fact that it did ask you to set home once at least means that it’s running. It’s likely running into an error somewhere.

              Honestly iOS and Safari (and Apple in general) were one of the worst developer experiences I’ve ever come across, which is why I’ve not looked into it at all so far … Actually I have looked into it just now, and I basically need an Apple device to do anything. Or virtualize Mac os which then virtualizes iOS, which probably costs some hours to all set up, yay. I hate this shitty company and its overpriced garbage.

              So yeah, sorry for that rant… but if you could search for some way to open the debug console of Safari and see some sort of error message I could probably do something. Apparently it’s somewhere in the advanced/developer settings.

              • Deez@lemm.ee
                link
                fedilink
                English
                arrow-up
                2
                ·
                1 year ago

                Thanks for looking into it. I did find the debug console setting while I was poking around earlier. It needs to connect to a PC so I’ll give it a go tomorrow.

  • JohnnyLX91@lemmy.zip
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    1 year ago

    If I already have it installed in Tempermonkey, is there a way to update or do I need to remove and download again?

    • Azzu@lemm.eeOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 year ago

      It updates automatically through your configured update interval, or you can go to the page and click “update”.

    • HeavyRust@lemm.ee
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      You can update all userscripts with Tampermonkey. For me, it was in Utilities -> Check for userscript updates.

  • Ferris@discuss.online
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    I don’t know if it’s intended behavior, but the ‘context’ button when viewing responses to your posts does not change to your home instance. I was trying to understand how to work around that yesterday. It appears the title link works, but now I’m not certain whether it’s because of the script.

    • Azzu@lemm.eeOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      Yeah that’s what I thought. This is how those buttons look in code:

      The problem is that there’s no destination identifier attached. If you compare that with your name at the top of your comment: , there’s an <a> (and href=) that identifies this as a link to somewhere. The buttons have no such identifying text with them, so I can’t rewrite them because I don’t know where they lead, it’s hidden within the application logic somewhere.

    • Azzu@lemm.eeOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      1 year ago

      I’ll take a look when I’m back home :) could be that the context links aren’t really “links” at all, but “buttons”, which aren’t detected by my script.

      If you look at the post, you see some screenshots/videos, there’s this little icon with two arrows in a circle that signifies if a link was rewritten, which is how you can check if it’s working.

    • Azzu@lemm.eeOP
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      Oh, I thought it had something to do with the script. I mean I guess I could keep defunct instances around, but idk how useful that would be, and how to verify that the domain didn’t change to something completely unrelated…