A script that inserts keyframes only for unlocked Transforms (Location / Rotation / Scale) for selected objects or bones. I mean, the fact that you can insert keys even when they are locked is strange ...
In Object Mode, add to Object → Animation → Insert Custom Property Keyframes In Pose Mode, add directly under the Pose menu: Insert Custom Property Keyframes Insert keyframes at the current frame for ...