Help make script work on all selected obj instead of just one
You can get all selected objects in:

objs = bpy.context.selected_objects


then just make a loop:

for obj in objs:


and then your code.

Done:

import bpy

objs = bpy.context.selected_objects
for obj in objs:
    for ipoly in range(len(obj.data.polygons)):
        for idx, ivertex in enumerate(obj.data.polygons[ipoly].loop_indices):
            ivert = obj.data.polygons[ipoly].vertices[idx]
            col = obj.data.vertex_colors.active.data[ivertex].color
            obj.data.vertex_colors.active.data[ivertex].color = tuple(1-x for x in col)