i find it annoying to have to manually change urls to subscribe to a community outside lemmy.world, so i wrote a bookmarklet to quickly switch to the lemmy.world instance

to use, just drag the following code to your bookmarks bar (name it whatever you like), then click it when you want to use it

javascript:(function() {const myInst="lemmy.world";let currUrl=window.location.toString().split("/");let currInst=currUrl[2];currUrl[2]=myInst;let newUrl=currUrl.join("/")+"@"+currInst;window.location=newUrl;})();

readable version:

javascript:(
	function() {
		// make sure to change this if using on a different instance
		const myInst="lemmy.world";
		let currUrl=window.location.toString().split("/");
		let currInst=currUrl[2];
		currUrl[2]=myInst;
		let newUrl=currUrl.join("/")+"@"+currInst;
		window.location=newUrl;
	})
()
  • Yoru@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 years ago

    Hello, I just made a new bookmarklet where it automatically transfers all of your subscribed communities to another instance, can be found here

  • God@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    3 years ago

    do you know of any way to switch not a community but a post to another instance? afaik they’re numeric so the number identifier is different on each instance which makes it hard.

    • Ɀeus@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      3 years ago

      i’m afraid i don’t. i did fiddle around a bit trying to find a relationship between url’s, but I couldn’t see one

      if anyone more familiar with lemmy/activitypub can tell me, I’ll update / add to the bookmarklet

  • Yoru@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 years ago

    also, you should replace const myInst="lemmy.world"; with const myInst = window.location.hostname;, it automatically fetches what instance you’re on.

    • Ɀeus@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      3 years ago

      that (unless i’m misunderstanding) isn’t the point of it. it’s made for quickly taking you from e.g. https://lemmy.ml/c/jerboa to https://lemmy.world/c/jerboa@lemmy.ml, so it needs a const to know which instance to take you to

      edit: i guess i could replace let currInst=currUrl[2]; with let currInst=window.location.hostname; but i can’t see a practical difference and so i chose the shorter one

  • Grenfur@lemmy.one
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 years ago

    Do you know if the process works differently in FireFox? (Note that technically I use Ghostery but it’s based in Firefox). I copied the script to a new bookmark URL and changed lemmy.world to lemmy.one since thats the instance I’m registered on. However, when clicked nothing happens. Is there something I’m missing?

    • Ɀeus@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 years ago

      i can tell you that i made and currently use it with firefox…

      sanity check, when you select edit bookmark it should look like this

      however, i don’t know about ghostery (i didn’t even know they made a browser). it’s possible they block arbitrary js for security reasons? it would be a dumb choice in my opinion, but i guess it’s protecting you from yourself?

      however i can tell you a couple of things. this doesn’t work with some communities (they just 404), but that happens if one puts the url in manually. i don’t know when or why this happens, but it does seem to happen a lot with lemmy.one. i wonder if it’s a l.1 federation issue