I am trying to run a script on active tab using option provided in chrome extension active tab. I am able to run using executeScript
option
chrome.tabs.executeScript({
code: "console.log('Hey there! from extn');"
});
Calling console.log('Hey there! from extn');
and localStorage.setItem("myKey", "Set From Extn");
works fine.
But if i call some other script snippet ContextHub.getStore('profile').setItem('myKey', 'Value from extn');
. It gives error Uncaught ReferenceError: ContextHub is not defined
when extension code is running. If I run the same snippet from dev console for that tab, it works. So ContextHub variable is defined for that tab.
Do we need some extra configuration/permissions for this or there is any other API to be used for this? I need to be able to run script on active tab though extension, which I am able to run through dev console.