Unfortunately, the short answer is that JavaScript does not have the ability to control the current frame of the Animated GIF.
The long answer is that there are several ways to do what you want with JS only, but they are very confusing.
An example of a hacker way: create a canvas and do not add it to the DOM (so that it will not be visible to anyone). In a fast cycle (setTimeout), constantly draw on this canvas and collect snapshots. Compare canvas ImageData to see if frames have changed.
It would be better to use your time, perhaps to find out how you can share its server for you (using php / perl / python / etc)
source share