0

Guys, I'm doing Chrome extension and I need:

  1. Get highligheted text;
  2. Count it and edit number in real-time;
  3. Get this number in popup or tooltip over mouse for 1 or few seconds.
  4. Maybe 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 itll get text from (1) and how send it to (3). And where'd I paste limitation code for (4)?

Thanks for help.

Arte
  • 31
  • 3

1 Answers1

0

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

Community
  • 1
  • 1
Mohamed Mansour
  • 39,445
  • 10
  • 116
  • 90