Hi!
Well, you an use the animCurveEditor command to check which curves are shown and then use a loop to set the names of those curves as args in the the setKeyframe command, if you want to have a keyframe on the same frame for every diplayed curve. Or you can set the name of the curves as args in the findKeyframe commands as well so you have a keyframe at that percentage relative to every curve.
But that would then render the program completely useless if the grapheditor isn't open or if there isn't any curve selected in it...
So you would have to first check if that is the case and then either run the function in "grapheditor mode" or in "timeline mode". Ofcourse you'd need to decide wether the grapheditor should have influence if it is just open or if it needs to be the panel in focus to matter, since that changes the way you will be querring for it.
And then you would have to decide how you want to split your grapheditor mode and timeline mode.
1) If they are decided in your checking function and always pass the names of all the active curves, the checking function just querries differently depending on the mode
2) If only grapheditor mode passes curve names and the insertKeyPercentage function works as a hybrid that decides how to act wether it gets passed curve names or not
3) If you want to have your grapheditor mode as an entirely new function and decide which function gets run in your checking function using an if else statement.
Ofcourse if you have a mode that discriminates based on the graph editor, why not also have a mode that dicriminates based on Channelbox Attribute selection, would make sense, right? So you have to decide all those things again for your channelbox mode and determine which mode has priority and based on what criteria...
Thats how I would approach a change like this. I won't write this as code though, since it is a lot of work and testing and some decisions that I can't take without a lot more information on the project...
I hope it helps!