Search code examples
javascriptfirefoxgetfirefox-addonselected

Firefox extension get text in context menu (javascript)


The first think i try was to get the selected text, but that is impossible in Firefox.Like this person Firefox extension getSelection().toString() not getting the selected text i read a lot other post and those code don't work in Firefox.

So i want to try another think. I have google search in context menu with already get selected text: IMAGE for Google Search And i want to get that text from the google search context menu.

The extension is page-translator. I fixed the "auto language" and want to add text translation. I am working in this almost 3 weeks and this is my last try. Here is the complete extension: https://www42.zippyshare.com/v/AS5RAMVR/file.html


Solution

  • I found the answer here for text selection

    https://github.com/mdn/webextensions-examples/blob/main/menu-demo/background.js

    info.selectionText