Chrome extensions content scripts live in isolated worlds
, meaning they share DOM, but have separate JavaScript sandboxes.
So your kango.invokeAsync
function and all variables are not reachable to content script
. If you want to make use of page JS Variables and functions define Content scripts as here.
var script = document.createElement('script'); // Create a Script Tag
script.src = chrome.extension.getURL("yourscript.js"); //Fetch the content script
script.onload = function () {
this.parentNode.removeChild(this); //Remove script after script executed
};
(document.head || document.documentElement).appendChild(script); //ADD script tag
//to head or Html element
Your code doesnot has any communication mechanism between content scripts and background page. Add a message communication system for all your functional requirements.
References: