1

I've created a Google Chrome Extension for personal usage, and I would like load external web page as if it were in its domain.

In example, suppose that I inject the content script mydomain.js when tab url match mydomain.com, and in that case I would load the external web page externaldomain.com/articles.html to parse this page when it's loaded.

I know that tipically this goal is reached via iframe or XMLHttpRequest, but both don't work. I think that externaldomain.com/articles.htmlperform some check that fails if not loaded in its own domain.

Someone has an idea about how simulate loading of externaldomain.com/articles.html like tab is in externaldomain.com ?

Extra:

actually my trick is open directly externaldomain.com/articles.html in a tab and inject a script (myextension-externaldomain.js): when tab is loaded this script parse the page, and then pass the result to mydomain.js via chrome messages passing. It works, but It's very awkward!

2
  • If you don't mean to show the html and just want to parse its response, you could moving your xhr logic to background page, they are not restricted by SOP. developer.chrome.com/extensions/xhr
    – Haibara Ai
    Jul 28, 2016 at 0:50
  • Unfortunately this doesn't work: my problem isn't due to origin policy error. My parse starts on window loads, and the right load happens only if I'm in that domain, otherwise the request goes right, but the appended responseText fails load it's scripts. Anyhow, thanks!
    – Sim Sca
    Jul 30, 2016 at 14:39

0

Your Answer

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