The concept you describe is implemented both by some commercial IC's and by discrete circuits such as the one below, designed by the great Dave Johnson.
After mains AC zero crossing positive going rising mains voltage couples to the gate of the MOSFET turning it on. The MOSFET connects the "ground" of the output circuit to the -ve of the input bridge rectifier BR1. The 470 uF charges to the so-far-still-low mains voltage.
The 220k:10k divider drives the 2N222 transistor base. When the mains voltages rises high enough to to turj on the transistor, the transistor clamps the MOSFET gate to its source, turning it off. This state continues until Vmains again falls below the critical level.
When the MOSFET is OFF the output circuit floats to rectified mains phase voltage above AC "neutral". Touch it and you may die.
Even if the circuit was rearranged so that output earth was at neutral when Vmains was high the circuit would still be a potential death trap.
Here is a very slightly altered version - same circuit - load wiring shown slightly differently to make it clearer that the whole output circuit is effectively alternately connected to Neutral and then to phase.
- "Interest only" and of not much effect on the output when considered in isolation - When rectified AC in is between about 3V and 8V the FET is on and output ground is one diode drop above the most negative AC lead. When Vin_AC > 8V the FET is off and Vout + is one diode drop below the most positive phase lead. So regardless of which input lead is phase and which is neutral, the output effectively "dances" between them every cycle.
Above is based on PDF here
For an explanation of this circuit (which effectively does what your idea does) see my answer here
Note very carefully that ALL parts or this circuit MUST be treated as if they were at mains voltage - as they may be. This is a very dangerous circuit and must only be used with a full understanding of and allowance for the dangers.
Circuits like this are prone to occasional sudden noisy & explosive failure with release of magic smoke. Mains spikes or dips or surges can "fool" the switching logic in various ways. While the concept is good the risk is so high that use of safer isolated supplies is almost always preferred. Even if the user is not endangered the circuit is liable to destroy the powered equipment "just because it can".