afelix / Mr. Gerbear List 2 Text

// ==UserScript==
// @name         Mr. Gerbear List 2 Text
// @version      0.3.3
// @description  For Eurovision favorites sorters. Adds a textbox containing the final list for easy copying.
// @author       Andrei Felix
// @match        http://esc.gerbear.com/sorter*.htm
// @run-at       document-end
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    var injScr=document.createElement("SCRIPT");
    injScr.innerHTML=`
    var showResult_ = window.showResult;
    window.showResult = function() {
        showResult_();
        var text = "", i = 0, idx, txtBox = document.createElement("TEXTAREA");
        txtBox.rows = 43; txtBox.cols = 70;
        for (idx of lstMember[0]) text += namMember[idx].replace(/<img[^>]*> <b>(.*)<\\\/b><\\\/?br>(.*)<\\\/?br><i>(.*)/,
            (match, p1, p2, p3) => ((++i) + ". " + p1 + ": " + p2.replace(/<br>/g, " ") + " - " + p3.replace(/<br>/g, " ").replace(/<\\\/i>/, "") + "\\r\\n")
        );
        txtBox.value = text;
        document.getElementById("resultField").appendChild(txtBox);
    }`;
    document.body.appendChild(injScr);
})();