Great extension!
Nonetheless I am facing an issue, I try to execute a script but this script needs to get the selection in the page,
const selection = window.getSelection().toString()
Of course this fails because when I am initiating a mouse gesture the text is deselected before the script runs, nothing surprising here.
My solution was to inject a piece of code in every page and will save the selected text on the window object.
window._previousSelection = undefined
document.addEventListener('selectionchange', () => {
const selection = window.getSelection().toString()
if (selection) {
window._previousSelection = selection
}
})
Nothing fancy, then in the mouse gesture script I try to read the value :
const selection = window._previousSelection
No luck... Now I believe it's because your extension is executing the script in its own world and can't access page window user defined properties.
What can I do?
Note: Maybe we could implement a placeholder for that (%s). I know you are already providing this placeholder for search text actions.
Another solution is to just run the script into the MAIN world.
I tried to check the option Inject JQ because I thought that's what it was, but still not working.
(I could open a PR if you show me what part in your code is responsible for executing a script)