I don't think that you will ever find a 100% secure way to do it. Problem with JavaScript is, it is always executed by the browser and not the server.
Most secure way is, that you program a server side tool, where your game connects to and the example is created on the server side when the game is completed. But this isn't something you can easily do with C2.