Overhauled the way the script determines which frame is active if there are more than one frame on a page
Fixed a bug with the last commit