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
    1
    ·
    1 year 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
      1 year 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/[email protected], 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