Skip to content

Instantly share code, notes, and snippets.

@clouddueling
Created February 6, 2014 21:17
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save clouddueling/3f134bbd98a65f9bf9b5 to your computer and use it in GitHub Desktop.
Save clouddueling/3f134bbd98a65f9bf9b5 to your computer and use it in GitHub Desktop.
Count number of watches in angular app bookmarklet. Add as URL in new bookmark and click.
javascript: (function () { var root = $(document.getElementsByTagName('body')); var watchers = []; var f = function (element) { if (element.data().hasOwnProperty('$scope')) { angular.forEach(element.data().$scope.$$watchers, function (watcher) { watchers.push(watcher); }); } angular.forEach(element.children(), function (childElement) { f($(childElement)); }); }; f(root); console.log(watchers.length);})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment