jay-knight / FindAGrave wikitree formatter

// ==UserScript==
// @name         FindAGrave wikitree formatter
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Format findagrave source into something suitable for pasting into wikitree.com
// @author       Jay Knight
// @copyright    2020, jay-knight (https://openuserjs.org/users/jay-knight)
// @match        https://www.findagrave.com/memorial/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';

  const source = document.getElementById("citationInfo").textContent.trim().replace(/(\r\n|\n|\r)/gm, "").replace(/  +/g, " ").replace(/Find a Grave Memorial ID (\d+)/, "{{FindAGrave|$1|sameas=yes}}");
  const newdiv = document.createElement("div");
  newdiv.textContent = source;
  document.getElementById("citationInfo").parentElement.appendChild(newdiv);
})();