The extension is unable to load the page's DOM after the submit action.
Before submitting it works. After the submit does not work.
Cannot read property 'body' of undefined
Thank you
manisfest
{
"name": "Nfe",
"version": "1.0",
"manifest_version": 2,
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
],
"browser_action": {
"default_popup": "popup.html",
"default_title": "Nfe"
},
"background":{
"scripts": ["background.js"]
},
"permissions": ["tabs"]
}
popup.html
document.querySelector('button').addEventListener('click', onclick, false)
function onclick () {
chrome.tabs.query({url:"http://site"}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {data:"OK"});
});
}
content.js
// Test load DOM
const interval = setInterval(()=>{
const conteud = document.querySelector("body")
console.log(conteud)
}, 1000)
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
const conteudo = window.document.querySelector("body")
var html = conteudo.outerHTML;
var data = { html: html };
console.log(data)
})