Please consider implementing the use case you are looking for using a LivePage.
This wiki page displays a rendered preview of the wiki page you are creating while you are typing.
Don't forget to periodically save your script. Previewing the content with the wiki page does not save it whatsoever.
For installation, just create a new wiki page with the content provided in the WikiPreview.txt file of this extension and you are good to go. No further extensions required.