I am trying to develop a Firefox extension. The trouble is I cannot figure out how to access the html of the activetab when the toolbar button is pressed. I have not added the toolbar button yet, I will do that once I get the function getHTML working.
This is the manifest file.
{
"manifest_version": 2,
"name" : "Example",
"version": "1.0",
"description": "Example extension",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["js/content.js"]
}
],
"background": {
"scripts": ["example.js"]
},
"permissions": [
"tabs",
"storage",
"activeTab",
"webRequest",
]
}
This is the background script example.js:
function getHTML() {
browser.tabs.query({
active: true,
lastFocusedWindow: true
}, function(tabs) {
// and use that tab to fill in out title and url
var tab = tabs[0];
var tabId = tab.id;
browser.tabs.executeScript(tabId, {
code : "console.log(document.body.innerHTML)"
})})};
getHTML()
What am I doing wrong?
Thanks in advance.