Fix magic js snippet to work on chrome also