Python script - apply only to selected
Blender stores a list of the currently selected objects in bpy.context.selected_objects. It's not always as easy as this, to only effect the selected objects, but for your example you would access the current action of the selected object with the animation_data.action property:

import bpy

for object in bpy.context.selected_objects:

    for fcurve in object.animation_data.action.fcurves:

        for point in fcurve.keyframe_points:

            point.co.x **=2