I\'m developing an extension where i need to get the entire text content on the current tab. Now i\'ve a plugin which retrieves selected text from the current tab. So, in essenc
Use executeScript: (requires permission activeTab
)
chrome.tabs.executeScript(null, {
code: `document.all[0].innerText`,
allFrames: false, // this is the default
runAt: 'document_start', // default is document_idle. See https://stackoverflow.com/q/42509273 for more details.
}, function(results) {
// results.length must be 1
var result = results[0];
process_result(result);
});
In case the code
is complex, it's possible to define a function in the content script and call that function in the code
(or use file
).