Adobe InDesign Javascript – Remove All Bookmarks

Recently while working on a dynamic template I noticed that things had got a little out of control on the Bookmark front and InDesign was crashing while trying to display the Bookmarks window. Subsequently found that this was because through the course of constantly updating the table of contents I had amassed over 75,000 bookmarks! Something was needed, so I wrote a small JavaScript for InDesign to systematically remove them all. main(); function main [...]