Get highlighted text, count it, take it to popup. Chrome extension
Guys, I'm doing Chrome extension and I need:
- Get highligheted text;
- Count it and edit number in real-time;
- Get this number in popup or tooltip over mouse for 1 or few seconds.
- Maybe开发者_如何学Go will have a limitation of characters like 3 or 4-digits numbers.
Please, need your help.
What I`ve got with Google and others:
For (1) I need this:
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if (request.method == "getSelection")
sendResponse({data: window.getSelection().toString()});
else
sendResponse({}); // snub them. });
Am I right?
For (2) I think I'd use String length but I dont understand how it
ll get text from (1) and how send it to (3).
And where'd I paste limitation code for (4)?
Thanks for help.
When you state put this number over the mouse for 1 or 2 seconds. You can do the entire thing in the content-script the code you stated. Then you can add a bubble overlay to show the number:
Text selection and bubble overlay as Chrome extension
精彩评论