Create a content script and use the following piece of code:
//Create a request listener chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { //Check if the requested method equals getSelection if (request.method == "getSelection") //Send back the selected text. sendResponse({data: window.getSelection().toString()}); else //Snub them. sendResponse({}); });
This will start a request listener. With this you can send a request named getSelect from your browser_action to the content_script.
To send the getSelect request you can use the following piece of code in your browser_action.
function selectedTextPaste() { //Get the current selected tab chrome.tabs.getSelected(null, function(tab) { //Send a request to the content script of the tab with as method getSelection chrome.tabs.sendRequest(tab.id, {method: "getSelection"}, function(response) { //do something with response.data }); }); }
And thats all you have to do! Now you can do whatever you want with the data the browser_action has received.