Skip to content

Instantly share code, notes, and snippets.

@Nitrousoxide
Last active June 29, 2023 09:02
Show Gist options
  • Save Nitrousoxide/0ad922d431749d6e4f7c9a35d40da4dc to your computer and use it in GitHub Desktop.
Save Nitrousoxide/0ad922d431749d6e4f7c9a35d40da4dc to your computer and use it in GitHub Desktop.
Lemmy Follow Bookmarklet
javascript:(function() {
var currentUrl = window.location.href;
var instanceUrl = 'https://beehaw.org'; /*replace this with your local instance's URL with no ending '/' */
var communitySlug = currentUrl.split('/c/')[1];
var originalUrl = currentUrl.split('/')[2];
var subscribeUrl = instanceUrl + '/c/' + communitySlug + '@' + originalUrl;
window.location.href = subscribeUrl;
})();
@fvbommel
Copy link

Here's a version that also works for a community from server A on server B:

javascript:(function() {
  const home = 'lemmy.world'; /*replace this with your local instance's host name */
  const url = window.location.href;
  let community = url.split('/c/')[1];
  if( !community.includes('@') )
  {
    community += '@' + url.split('/')[2];
  }
  if( community.endsWith( '@' + home ) )
  {
    community = community.substring(0, community.length - 1 - home.length);
  }
  window.location.href = 'https://' + home + '/c/' + community;
})();

@wccrawford
Copy link

Here's a version that also works for a community from server A on server B:
Thanks for this! It's working great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment