I don’t believe this would be possible through scripting, but i may be wrong.
There are numerous ways within zbrush to mask, which are far better than the grow/shrink method of other apps, one way which is close however is the topological masking. I admit zbrush’s methodology is different and sometimes opposite from what we are used to but for myself after finally becoming comfortable with z, i find my workflow sped up much more than in other apps, in fact its become cumbersome to even go back to them and attempt modeling, they seem clumsy, although i guess it all depends on how your brain works. Don’t give up on zbrush’s strange ways of doing stuff, you may find that it makes you think outside the box, which i personally love.
Remember there is masking by selection, topological, hiding/selecting, polypaint convert to masking. there are also options for sharpening or smoothing your mask, as well as the blend option.