Kris wrote a guest article on the Adobe.io blog.
If the information is useful, please give the article a few ‘hand-claps’ by clicking the icon at the end of the article. This helps raise the article’s profile!
Have a look here:
https://medium.com/adobe-io/how-to-write-an-indesign-call-on-idle-script-6b540073f391