0

I have a chrome extension that needs to parse several pages on a domain. I normally do this by using a background XHR and then send the response into jquery.

$(xhr.responseText)

However, the response from the XHR does not contain all the HTML and JQuery is not processing the dynamic content. The pages use AngluarJS ng-view and that portion of the page is not populating. The data can not be queried directly as it appears to be proxied.

Simplified XHR response minus js:

<html lang="en" ng-app="ngApp" id="ng-app" ng-class="viewName">
    <body ng-controller="AppController">
        <div class="container-fluid" id="maincontent" tabindex="-1">
            <div ng-view autoscroll="true" data-ng-animate="{{viewAnimation}}"></div>
        </div>
    </body>
</html>

I've spent days reviewing these pages - can't figure it out, AngularJS is foreign to me. Can't get $compile to work, property of invoke undefined, and other hair pulling. I'm lost.

Is there a way to have a chrome extension process the XHR return to capture the remaining dynamic code?

4
  • You can try adding an iframe in the background page DOM for the remote site and strip its X-Frame-Options, then extract the processed html in onload + timeout or MutationObserver to catch the moment when DOM was dynamically updated by the page script. Commented Feb 26, 2017 at 18:01
  • I was able to load the iframe I think in the background, but I'm running into cross-origin issues trying to read the DOM. Commented Feb 27, 2017 at 2:28
  • Add the URL you need to access to "permissions" key in manifest, see the docs for an example. Or <all_urls>. Commented Feb 27, 2017 at 5:55
  • Already had, permissions don't appear to work for iframe. According to a comment on this post stackoverflow.com/questions/5724135/… permission "only applies to cross-origin XMLHttpRequests, injecting content scripts, and reading cookies. It does not apply to reading an iframe within a background page." Looking at maybe trying a content script in the iframe. stackoverflow.com/questions/40248467/… Commented Feb 27, 2017 at 12:26

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.