Creating a chrome extension which takes highlighted text on the page and inserts it into a textarea in popup.html

前端 未结 2 1560
情话喂你
情话喂你 2020-12-24 04:11

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

2条回答
  •  既然无缘
    2020-12-24 04:55

    popup.js

    chrome.tabs.executeScript( {
      code: "window.getSelection().toString();"
    }, function(selection) {
      alert(selection[0]);
    });
    

    manifest.json

    "permissions": [
        "activeTab",
    ],
    

    Have a look at this simple extension https://github.com/kelly-apollo/zdic

提交回复
热议问题