Skip to content

Instantly share code, notes, and snippets.

@jeena
Created June 28, 2023 02:54
Show Gist options
  • Save jeena/0e967baafc87b5ec1ccadffa0412c304 to your computer and use it in GitHub Desktop.
Save jeena/0e967baafc87b5ec1ccadffa0412c304 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Lemmy simplified subscribe
// @namespace net.jeena.lemmy
// @version 0.1
// @description When not logged in, on a community page replace the name of the community with a link to your own instonces search.
// @author Jeena
// @match https://*/c/*
// @match https://*/post/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var my_instance = "https://example.com";
function addSubscribeLink() {
var code = document.querySelector("div.alert-info code.user-select-all");
if(code && ! code.querySelector("a")) {
var community = code.innerText;
var path = my_instance + "/search?q=" + encodeURIComponent(community) + "&type=Communities&listingType=All&page=1&sort=TopAll";
var link = "<a href='" + path + "'>" + community + "</a>";
code.innerHTML = link;
}
setTimeout(addSubscribeLink, 1000);
}
addSubscribeLink();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment