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;
	})
()

top 10 comments

sorted by: hot top controversial new old
[โ€“] 1 point 3 years ago*

Thanks that super useful, especially in places like /c/newcommunities where people (including me) are still unsure how to properly link communities.

  • source
  • [โ€“] 1 point 3 years ago (1 child)

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

  • source
  • hideshow 1 child comment
  • [โ€“] [S] 1 point 3 years ago* (last edited 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

  • source
  • parent
  • [โ€“] 1 point 3 years ago (2 children)

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

  • source
  • hideshow 2 child comments
  • [โ€“] 0 points 3 years ago* (last edited 3 years ago) (3 children)

    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.

  • source
  • hideshow 3 child comments
  • [โ€“] [S] 0 points 3 years ago* (last edited 3 years ago) (2 children)

    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

  • source
  • parent
  • hideshow 2 child comments
  • [โ€“] 1 point 3 years ago (1 child)

    Staying on your home instance is currently an issue on the repo. Implementing it yourself would need using the search, which is complicated because it only works through a websocket connection.

  • source
  • parent
  • hideshow 1 child comment
  • [โ€“] [S] 1 point 3 years ago

    i'm glad that's being tracked, as a bookmarklet is not really a great solution; but it's still not a complete solution. if i visit a lemmy post from outside lemmy.world (e.g. search engine), then there's no way to go to the l.w version (to my knowledge)

  • source
  • parent
  • load more comments
    view more: next โ€บ