first of all, thanks so much for looking into this...
It is EXACTLY what I wanted... golly it is even the right size and color!!!
At first I did not think it was working but then realized I had to first select all notes for it to work... and then it does it perfectly.
So clearly I can make a custom action to select all notes and then run this lua...
however, that brings to mind a thought about a refinement... I'll explain and perhaps you will tell me what you think.
What if, instead of directly deleting the grayed out notes, it set them all to muted... but left them in place ...so that the user could listen and think about possibly unmuting a few here and there in the future...
...and then having another script that would look at the track and delete all muted notes...
I'm thinking that way a few custom actions could be made.
One to simply select all,directly delete, then unselect all.
Another to select all, set unwanted grayed out to mute, then unselect all.
and then the delete all muted lua could be tacked on the the end of that or run separately...
Good idea or am I off the deep end?