How to automatically merge disconnected bones' heads and tails
Quick Script.

As commented, might pay to upload file with armature if more detail like bone roll is required.



Similarly to Straighten all bone chains in an armature a quick little script (in this case) to move parent tail to child head, connect and remove last bone.

In edit mode, grab the parent bones of chains you wish to "flatten and connect"

import bpy
context = bpy.context
arm = context.object.data
for eb in context.selected_editable_bones:
    parent = eb        
    while len(parent.children):

        bone = parent.children[0]
        parent.tail = bone.head
        bone.use_connect = True
        parent = bone
    else:
        print("remove bone", parent.name)
        arm.edit_bones.remove(bone)


Note haven't done anything for bone roll. Would probably use the Y axis of original bone as Z or X axis of re-positioned bone