jay-knight / FindAGrave wikitree formatter

// ==UserScript==
// @name         FindAGrave wikitree formatter
// @namespace    http://tampermonkey.net/
// @version      0.1
// @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 no. (\d+)/, "{{FindAGrave|$1|sameas=yes}}");
  const newdiv = document.createElement("div");
  newdiv.textContent = source;
  document.getElementById("citationInfo").parentElement.appendChild(newdiv);
})();