somedude

joined 1 year ago
[–] somedude@lemmy.pryst.de 4 points 1 year ago (3 children)

Gibt's für Lemmy keine Bot-API?

 

Hi,

ich habe hier ein kleines Tampermonkey-Script zusammengetippt, was bei einer Remoteinstanz einen Link auf die Suche nach der Community in der Heimatinstanz anzeigt. Das ganze funktioniert, wenn der Link der Community in der Alarm-Box rechts steht:

You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !ankuendigungen@feddit.de

https://i.imgur.com/jSVY19F.png

https://i.imgur.com/5iijXd5.png

Sicher nicht perfekt, Verbesserungsvorschläge gern gesehen. Public Domain Lizenz.

// ==UserScript==
// @name         Add Remote Community Link to Lemmy Descriptions
// @version      0.4
// @description  Add a link to a remote community description in the form of "https://home.tld/c/community@remote.tld"
// @author       SomeDude
// @match        https://*/c/*
// @match        https://*/post/*
// @match        https://*/comment/*
// @grant        none
// ==/UserScript==

window.addEventListener('load', function() {
   const home = "feddit.de";
   const communityDescription = document.querySelector(".alert.alert-info");
   if(communityDescription) {
     const remCom = communityDescription.textContent.match(/(!.*@.*)/)[1];

      // Create the remote community link
      const remoteCommunityLink = document.createElement("a");
      remoteCommunityLink.href = `https://${home}/search/q/${encodeURIComponent(remCom)}/type/All/sort/TopAll/listing_type/All/community_id/0/creator_id/0/page/1`
      remoteCommunityLink.textContent = `Search on ${home}`;
      remoteCommunityLink.target = "_blank";

      // Append the link to the community description
      communityDescription.appendChild(document.createElement("br"));
      communityDescription.appendChild(remoteCommunityLink);
  }
}, false);
[–] somedude@lemmy.pryst.de 3 points 1 year ago

...dann mach das bitte public :-D

[–] somedude@lemmy.pryst.de 1 points 1 year ago (1 children)

Did you use the ansible script? I found it to be pretty easy to use, with 1 or 2 very minor hickups along the way.