Help with 'visibility animation keys for collections' script modification

I found this very useful script:
This script Works fine but when you have 10+ collections to manage visibility it can become a mess.
Thats because it toggles the visibility and let it as is when you stop timeline. So if you hit play again the collections visibility are as when timeline stopped last time and not as it should begin.
Would it be easy to mod it so collections visibility state are more specific?

Hope I made clear what I mean,
With regards!