0

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

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.