Diskuse » Development

Right click -> selected text?

§
Posted: 09. 04. 2023

Hi

I hope I'm posting this in an acceptable place, but so far I haven't found anywhere else to get support for this kind of stuff so apologies in advance if I'm not supposed to post this here.

Running tampermonkey, using @run-at context-menu to get a new right click option on the page im using. When using chrome on mac, if you right click, it gives you the option to do a couple different things with the text that it has selected automatically when you clicked.

Does anybody know how to recall this text? Honestly just trying to use it for a stupid little web game and all i need are some small calculations, so i was hoping to be able to just adapt the content menu to show the result of the desired calculations (ie, say the desired calcuation is just 'x2 selected text' - if you right click and the auto-select is 10 - the context menu will just display the number 20) I'm not even looking to make the actual menu button do anything, just display information. Providing this context just in case i grossly misunderstood something and this isn't something that is possible to do.

thanks for any feedback in advance

§
Posted: 10. 04. 2023
Edited: 10. 04. 2023

This is a JavaScript question, to get the selected text simply do: window.getSelection().toString();

Post reply

Sign in to post a reply.