8

Is there anyway to see all ongoing setIntervals

If I make intervals global

b = setInterval(function(){
  $("body").append("B <br>");
},500);

I can see them when I, but I can't really see that they are intervals.

console.dir(Object.keys( window ));

Array[15]
    0: "top"
    1: "window"
    2: "location"
    3: "external"
    4: "chrome"
    5: "v8Intl"
    6: "v8Locale"
    7: "document"
    8: "jQuery171033813792187720537"
    9: "resizeJSBin"
    10: "$"
    11: "jQuery"
    12: "a"                            <--this is an interval!
    13: "local"
    14: "b"                            <--this is an interval!
    length: 15
        __proto__: Array[0]

Is there anyway to get information about all the intervals being run at a particular time. Like, see at what interval they are running, what code is being executed at that interval?

JSBIN

1252748
  • 14,597
  • 32
  • 109
  • 229
  • 3
    There's nothing built-in that does this. You can make a wrapper that will call `setInterval`/`clearInterval` for you, so you can keep track of them. – gen_Eric May 07 '13 at 21:39
  • 2
    http://stackoverflow.com/questions/858619/viewing-all-the-timouts-intervals-in-javascript – Adil Shaikh May 07 '13 at 21:40
  • @MohammadAdil It's a duplicate then. Vote to close – Ian May 07 '13 at 21:41
  • @RocketHazmat would there be a way to do this from the console on a third-party site so you could see what exactly the page is running on your computer? Thanks! – 1252748 May 07 '13 at 21:42
  • @Ian Does the fact that I'd like to be able to do this from the browser console set it aside as sufficiently different? – 1252748 May 07 '13 at 21:43
  • 1
    @thomas I believe you're coming too late if you're coming with the console – John Dvorak May 07 '13 at 21:43
  • 1
    @thomas: If you could "install" your wrapper before any of the code was ran, then probably. However, you can probably use your browsers other debugging tools to see what's going on. – gen_Eric May 07 '13 at 21:43
  • @thomas it's only so different that the answer would be; "no, you have to intercept the page load" – John Dvorak May 07 '13 at 21:44
  • @RocketHazmat Okay, cool. Can you give me an example of how to do that? – 1252748 May 07 '13 at 21:44
  • 2
    A user-script might be able to instrument SI in time, then you could query the interceptor from the console – John Dvorak May 07 '13 at 21:45
  • @thomas: Sorry, but I can't. I'm just good at throwing out ideas ;-) Not sure if any of them will really work. – gen_Eric May 07 '13 at 21:45
  • @JanDvorak Do you know of any scripts that would be able to do this? – 1252748 May 07 '13 at 21:47
  • @thomas I suggest writing one. I'm not aware of any such script existing, but there could be. Such a script is not difficult to write. – John Dvorak May 07 '13 at 21:48
  • `setInterval = (function(oldSI){return function(){...}}(setInterval)` – John Dvorak May 07 '13 at 21:50
  • most of the work would be to convince the userscript manager to run your script _before_ the page load. – John Dvorak May 07 '13 at 21:51

0 Answers0