new version of the generator using PhantomJS and regex substitutions