0

I'm trying to interact with a website using an userscript, but I don't know what's the cleanest possible solution for an outside source to detect the internal $viewContentLoaded event, because it does not bubble to the window object.

I tried using dirty workarounds, but I'm wondering how one could achieve a clean window level detection of the $viewContentLoaded event. The website in question is using 1.3.14 according to window.angular.version

user1263513
  • 91
  • 1
  • 8
  • Can you modify the Angular app? – Will Feb 23 '17 at 20:39
  • you should use caution when attempting to do this. it is *extremely easy* to make changes outside angular's context which angular is not aware of, putting the app into a state where it does not properly update it's information, leading to the page (and your script, potentially) providing inaccurate information. – Claies Feb 23 '17 at 20:41
  • Use `angular.element(HTMLelement).scope()` to get access to an Angular app scope. See [AngularJS angular.element API Reference - jqLite Extras](https://docs.angularjs.org/api/ng/function/angular.element#jquery-jqlite-extras). – georgeawg Feb 24 '17 at 04:33
  • @Will Do you mean whether the app is hosted by me? In that case, no, it's someone else's website. @georgeawg I'm not quite familiar with Angular. When should I use `angular.element(document.querySelector("body>.ng-scope")).scope().$on` to attach a listener to the target element? – user1263513 Feb 24 '17 at 16:30

0 Answers0