I have spent several hours searching the web for solutions. What I would like to do is take the highlighted text on a page and transfer it to a textarea in the popup.html of the chrome extension. I was wondering if someone could supply me with suggested source code of an extension that could do this.
This is the most pertinent thread I looked at that i thought would be most helpful – query is similar. Button in popup that get selected text – Chrome extension
I tried copying the code and running it as an extension, it does not obtain the highlighted text. Was wondering if anyone had any suggestions and how to solve this problem. Thank you very much.
Well just like the answer to the question you linked, you will need to make use of Message Passing and Content Scripts. That code is over 2 years old though and makes use of depreciated methods such as
onRequestandgetSelected. A few simple modifications should be plenty to update it to the new api’s.Popup.html
popup.js (so as to not have any inline code)
selection.js
manifest.json
Here is a link to source files.