Regarding DC conversion. Somewhere in the trolley is a so-called bridge-rectifier component - thumbnail sized and with 4 terminals. This takes the 2 wires with the AC track voltage and converts it to 2 wires with a DC voltage. The trolley motor operates on DC voltage. Reversing the DC voltage (i.e., swapping the two wires going to the motor) reverses the motor direction. The bump-n-go trolleys have sliding electrical contacts that perform this swapping ping-pong style when hitting the bumpers.
So. Several of the methods proposed perform the DC voltage reversing on the track voltage itself. For this to "work" you have to then bypass the bridge-rectifier in the trolley so that the track voltage is directly applied to the motor. In these direct DC methods, the sliding electrical contacts are not used and the trolley does not have to bump at each end. But bypassing the bridge-rectifier more than likely requires soldering, re-working potentially short and tiny wires so it can be a nuisance. And you'd have to post several close-up photos so one of us can identify the necessary modifications...and of course trust that we don't abandon you along the way with everything dis-assembled should problems develop!
OK, I'm game to explore using the trolley as-is using the method you propose. A couple questions first and I'll explain my thinking.
1. For the intended speed of operation (determined by your throttle setting), how quickly does the trolley stop when you instantly remove track power by, say, pulling the plug to the track? I suspect this will be something like 3-6 inches but try it a few times at a few different suitable speeds.
2. Say the trolley is stopped near the bumper but has NOT yet bumped to reverse. If you instantly apply track power by, say, connecting the track wire to the transformer (transformer being already set to the desired operating speed), how close can the trolley be to the bumper? In other words there will be minimum distance for the trolley to accelerate and develop enough momentum to reliably activate the sliding electrical contacts which reverses the DC voltage to the motor. What is that distance? I suspect it will be more than 1" but it is what it is.
So expanding on your idea,
Trolley approaches end of line. Infrared sensor (possibly the IRS-2 if we figure it out) detects trolley and triggers a relay. Relay removes power to entire track for 30 seconds. Trolley stops before end of track but far enough away from bumper per question 2 above. Power is restored, trolley accelerates to speed, bumps and reverses, goes other direction passing detector. But in this case the trigger is ignored (more on this in a second). Trolley reaches other side and a 2nd infrared sensor performs same operation. In fact the same relay module can be used if either detector can trigger the module.
So the man-behind-the-curtain is some method to disable or ignore the infrared sensor for some length of time after stop so that the 30 second interval does not immediately start again. Well, there are low-cost timer modules that have this kind of timing capability. We can get into specifics but first let me know if I'm heading in the right direction!