开发者

Get highlighted text, count it, take it to popup. Chrome extension

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开发者_如何学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 itll 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜