May be a throttle position sensor. The square plug from the TPS is the one for the transmission TCU. The grey wire from the TPS is the reference voltage, it is often around 4.6-4.8 V (supposed to be 5 volts but it never is), the blue wire is the out voltage and typically right around 4 V (3.8-4.0 V) and the voltage falls at the blue wire as the throttle is opened. The black is ground, the grounds are prone to corrode in numerous locations and eventually end up at the dipstick holder. There is a slight built in resistance in the TCU ground circuit in every Renix ( 87-90) XJ I've ever tested.
There is a formula for adjusting the TPS, but my numbers will give you a good quick check (good enough).
Testing is done with the connector connected and ignition in the run position. I usually slit (sharp knife, exacto etc.) the wire insulation, a little, lengthwise for my probes. I've never had it cause me any grief to leave a little wire exposed, you can reseal it with a dab of silicon if it bothers you. If you run the TPS wires over the rubber TB intake, life will be much easier for you.
If you can manually shift (2-3) but it will not shift itself in drive, it is most often the inline fuse to the TCU in the harness under/behind the glove box. Hard to see, a single, spade type, fuse holder wired to the outside of the harness, you don't have to remove the glove box. You may have to remove the bottom knee panel from the dash, the TCU is on the back of the dash knee panel passengers side.
The other half of the TPS is for engine controls and usually the one that screws up after an engine wash. 3000 RPM idles aren't unusual after the engine half of the TPS gets full of water.