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: [email protected]

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/[email protected]"
// @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);
  • @NoXPhasma
    link
    31 year ago

    Ich habe dein Script mal erweitert, nun fügt es neben einem hinzufügen Link auch einen öffnen Link hinzu.

    // @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/[email protected]"
    // @author       SomeDude
    // @author       NoXPhasma
    // @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 openOn = communityDescription.textContent.match(/!(.*@.*)/)[1];
         const searchOn = communityDescription.textContent.match(/(!.*@.*)/)[1];
    
          // Create the remote community link
          const remoteCommunityLink = document.createElement("a");
          remoteCommunityLink.href = `https://${home}/c/${openOn}`
          remoteCommunityLink.textContent = `Open on ${home}`;
          remoteCommunityLink.target = "_blank";
    
          // Append the link to the community description
          communityDescription.appendChild(document.createElement("br"));
          communityDescription.appendChild(remoteCommunityLink);
    
          const remoteSearchLink = document.createElement("a");
          remoteSearchLink.href = `https://${home}/search/q/${encodeURIComponent(searchOn)}/type/All/sort/TopAll/listing_type/All/community_id/0/creator_id/0/page/1`
          remoteSearchLink.textContent = `Add to ${home}`;
          remoteSearchLink.target = "_blank";
    
          // Append the link to the community description
          communityDescription.appendChild(document.createElement("br"));
          communityDescription.appendChild(remoteSearchLink);
      }
    }, false);