Inspired by Manuel's script for positioning the playhead in a layer...

Update: In addition to wrapping around in either direction, the NextFrame and PreviousFrame scripts now check if the current frame (playhead position) is outside the layer frame limits. It automatically moves to either the first OR the last actual frame of the layer, depending on if the frame number is outside, to the left (before) or, outside to the right (after). Once in range the playhead wraps around as before.