Text export ignore master pages

I need to alter the Export All Stories applescript in InDesign but I would like it to ignore stories on master pages and hidden layers.