OK, I just tried that:
The relevent section of my manifest.json reads:
"content_scripts": [
{
"matches": ["*://*/*"],
"js": ["node_modules/es6lib/dom.js", "content_script.js"]
}
],
I did an NPM install on windows from the root of the addon as follows:
C:\Moo\phpBB\quick>npm install --prefix . ..\NiklasGollenstede-es6lib-v0.0.2-0-g
e0da2b6.tar.gz
The directory was created and the output was:
C:\Moo\phpBB\quick
└── es6lib@0.0.2
When I attempt to load the addon through the debugging panel, I get the following error in the browser console:
TypeError: global is undefined, can't access property "es6lib_dom" of it
The code for my content_script.js is:
(function(global) {
const { readFromClipboard, } = global.es6lib_dom
var clickedElement = null;
document.addEventListener("mousedown", function(event){
//right click
if(event.button == 2) {
clickedElement = event.target;
}
}, true);
browser.runtime.onMessage.addListener(function(RunParse, CommandString, sendResponse) {
var CallFunction = RunParse.runwhat;
var ArgString = RunParse.ParseArg;
CommandParse (ArgString);
sendResponse({value: clickedElement.value});
});
async function CommandParse(ArgString) {
// Get Info About Textbox
var TextBoxName = clickedElement.getAttribute('name');
var TextBoxID = clickedElement.getAttribute('id');
var FocusInfo = document.activeElement;
var txtcont = document.getElementById(TextBoxID).value; //contents of edit box
var selstart = clickedElement.selectionStart; // index of selectin start
var selend = clickedElement.selectionEnd; //index of selection end
var selcont = txtcont.substring(selstart,selend); // selected text content
var firsttext = txtcont.substring(0,selstart); //stuff before the selection
var lasttext = txtcont.substring(selend); // stuff after the selection
//var clipcont = readClipboard (); //contents of clipboard
/*
console.log("moo:",moo);
// ...
const moop = await readFromClipboard('text/plain');
console.log('`moop` is:', moop);
// ...
*/
//simplified pasting
}
})();
Am I missing something?