-
-
Save jeena/0e967baafc87b5ec1ccadffa0412c304 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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