There is this active thread about a script with basically the same purpose:
https://forum.doom9.org/showthread.php?t=174410
The script MysteryX is working on still needs tweaking I think. I played around with it myself an came up with the script in this post (same thread as above):
https://forum.doom9.org/showthread.p...37#post1804437
It's a lot more full on than your script, and a little more full on that MysteyX's combined script, but I found it handled some things better.