How can I run a script outside the generateScript method?

Take a look at this example: