Updated JS to be more Firefox-friendly