Is there a script that hides Grease Pencil strokes?

I’m looking for a script that hides all Grease Pencil strokes outside the viewport, but leaves all the strokes in the current view unhidden.