I am wondering if it is possible to store the contents of the clipboard in a string variable.
The following source states that this is not possible using pure JS, b
There was an experimental clipboard api a while ago, I guess they removed it though. You could always paste the contents into a textarea/contenteditable and get it's value:
function getClipboard() {
var el = document.createElement('textarea');
document.body.appendChild(el);
el.focus();
document.execCommand('paste');
var value = el.value;
document.body.removeChild(el)
return value;
}
console.log(getClipboard());