Refactor animation prevention into own method

I intend to do some work to this file, and the levels of nesting made it
harder to understand what was going on.
Refactor snapshotting into own method

I intend to do some work in this file, and I wanted to clean it up a bit
first.
Wait until page is ready before taking snapshot

Before this commit, we used to wait five seconds before taking the
snapshot. We did this to make sure that asynchronously loaded
elements had time to render on the page. This solved most of the
problems, but we always wanted something more robust. This commit
attempts to replace the timeout-based solution with one that listens
events fired when resources are fetched, and trigger the snapshot as
soon as we're no longer waiting for anything.

PhantomJS has two methods that you can implement to solve things like
this: `onResourceRequested` and `onResourceReceived`. We implement these
and keep a list of active resources. As soon as a (potentially) last
resource is received, we start a short timer which will trigger the
snapshot to be taken. If another resource is needed within the timeframe
of that running timer, we cancel the snapshot-taking and start waiting
for the response for the (potentially) last resource once more.

If this strategy for some reason fails, there's a 20 second fallback
timer that will trigger the snapshot. And in case no resources are
requested from the page at all, there is a 1 second initial timer that
will trigger the snapshot.

All in all, a fairly complicated structure. My initial testing shows a
significant improvement though. Fast pages are snapshotted way faster
(down to 2.5 seconds) and I haven't noticed any issues with more
complicated pages.