this post was submitted on 14 Jun 2023
20 points (100.0% liked)

de_EDV

3805 readers
1 users here now

Ableger von r/de_EDV auf Lemmy.

News, Diskussionen und Hilfestellung zu Hard- und Software

Diese Community dient als Anlaufstelle für alle IT-Interessierten, egal ob Profi oder blutiger Anfänger. Stellt eure Fragen und tauscht euch aus!

Weitere IT Communitys:

[email protected]

[email protected]

[email protected]

[email protected]

founded 1 year ago
MODERATORS
 

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);
you are viewing a single comment's thread
view the rest of the comments
[–] NoXPhasma 3 points 1 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);