I have a problem developing chrome extensions.
I have a content script:
window.addEventListener("load",function(){
var html = document.getElementsByTagName('html')[0];
var title = document.getElementsByTagName('title')[0].innerHTML;
if(html){
chrome.extension.sendRequest({akce: 'content', title: title},function(response){});
alert(title);
}
},false);
then I have a BG page:
chrome.extension.onRequest.addListener(function(request,sender,sendResponse){
if(request.akce == 'content'){
console.log(request.title);
}
});
The problem is that when I start typing on the address bar, my script content is uploaded to the site, which is the first in the autocomplete list. As you can see in the screenshot below, the contents of the script are loaded before I press Enter in the address bar and load on the site where I have not been.
I have no idea what is going on. Please help me.
screenshot
source
share