Hi
copy/paste the code into a code editor.
I recommend you use Adobe ExtendScript Toolkit.
Then save and name the script file in javascript format here : [...]Adobe InDesign\Scripts\Scripts Panel.
Finally, in Indesign, choose Window > Utilities > Scripts.
Double-click or right-click to execute the script.
That's it.
The script above inserts a new page, based on a Master page, every 8 pages.
Further explanation for Line 15 :
for(var i=6;i<=doc.pages.length;i+=8){
i=6 means script will start including new page AFTER page 7 (looks strange but note that javascripts starts counting at... 0!)
i+=8 means it will repeat the operation every 8 pages. So the result here will be pages 8, 16, 24, 32... will be inserted.
Understanding that, you might have to modify the code, depending on how you want it to act.
Hope that helps
Vinny
Please note there is a specific indesign scripting forum here: InDesign Scripting