Copy all mails to clipboard

2023-04-14 - Extension for foodsharing.de - Collect all email addresses of the listed groups and copy them to the clipboard

// ==UserScript==
// @name        Copy all mails to clipboard
// @namespace   Violentmonkey Scripts
// @match       https://*.foodsharing.*/*
// @run-at      document-idle
// @version     1.2
// @author      Martin G.
// @license     MIT
// @require     https://cdn.jsdelivr.net/npm/@violentmonkey/shortcut@1
// @description 2023-04-14 - Extension for foodsharing.de - Collect all email addresses of the listed groups and copy them to the clipboard
// ==/UserScript==


let btn = document.createElement("BUTTON");
let div = document.querySelector(".metanav-container");
div.appendChild(btn);
btn.innerHTML = "Copy";

btn.onclick = () => {
  var liste = "";
  var links = document.querySelectorAll("a");

  Array.prototype.forEach.call(links, function(link) {
    if (link.href.indexOf("mailto:") != -1) {
      liste += link.href += ";";
    }
  })

  liste = liste.replaceAll("mailto:", "");
  navigator.clipboard.writeText(liste);
};