What I would do is check ground points battery to fender, battery to frame, battery to motor. Then check to see if you have motor to cab fire wall.The windows do that some times due to contacts being dirty or corroded. Get some electric contact cleaner and spray the wire ends to the window motor.
The tail gate is only grounded by the hinges and they rust causing it to lose ground. Some of the other guys out there can give you more details. My memory is not to sharp today so I am foggy on what you should get for reading on a voltmeter.
Hope that helps you some on sorting it out. I am sure you know to be sure contact points are clean.