Reputation: 6217
I have a Chrome extension which is injecting some code into a web page (I know that part's working), which is trying to call a function that is part of the original web page. The function works fine from the console, but gives an error when the extension calls it. I assume this is some sort of security feature, but is there a way to get around it? Please help!
PS. It's just for one website, if that helps
Upvotes: 0
Views: 1104
Reputation: 8472
You can't do it with content scripts. Chrome extensions content scripts live in isolated worlds, meaning they share DOM, but have separate JavaScript sandboxes. Read more here:
The workaround to this is to inject a <script>
into the DOM of the page, but that code won't have privileges to call any chrome.*
APIs.
Upvotes: 1