Trying to Read Contents of Clipboard

The thing is that I know of some people, myself included, who are using FF 56 because the extensions are still missing.

I found the solution here. I’ve incorporated the fix to the minor fix he was looking for:

function readClipboard () {
field = document.activeElement;
let area = document.createElement("textarea");
//document.body.appendChild 1(area);
field.parentNode.append(area);
area.contentEditable = true;
area.textContent = '';
area.select();
console.log('Pre-paste: ' + area.value);
console.log(document.execCommand("paste"));
console.log('Post-paste: ' + area.value);
area.setAttribute("style","display:none;");
return area.value;
}

It returns the contents of the clipboard when running from a CONTENT script.

I should note that I do not understand the above script, I’m a novice Javascript jockey, but I have been able to get the selection and the clipboard contents, which means that I can replace the clipboard and selection tokens with the value of using regexp:

argstring = argstring.replace(/{{clipboard}}/g,clipcont)
argstring = argstring.replace(/{{selection}}/g,selcont)

(I’ve not checked the code yet)

Now onto specifying a popup.