Restore All Materials

Perhaps you should look into material param collection instead.

Think of it as if it was a global variable that can be applied to many materials at once. Rather than replacing all materials and restoring them, you could use a single vector to change their look - turn them black, for example.