If your goal is to qualitatively detect the presence or absence of a mains voltage, rather than quantify it, there are some approaches which may avoid the need for transformers or opto isolation. The basic principle is very simple: use safety rated components which will only let through a tiny amount of current even under adverse circumstances, and then use a very sensitive circuit to detect that current. If one builds a capacitive voltage divider using two safety-rated 22pF caps in series on the line side, and a 0.001uF cap on the line side, the voltage on the output cap will be about 1/100 of the input voltage in the absence of any other loading. If one then feeds the voltage on the output cap through a 100K resistor into a very sensitive instrumentation amplifier, then even a 10,000 volt spike on the input would be incapable of producing more than 100 volts on the 0.001uF cap, which would in turn be incapable of pushing more than 1mA through the 100K resistor.
The primary difficulties with this kind of circuit are (1) you need to make sure that the safety-rated caps are mounted and connected in a way which does not compromise their safety rating, and (2) the detection circuit needs to have very low leakage currents. Leakage currents in the detection circuit won't create any shock hazard (unlike improper mounting or connection of the safety-rated components), but may cause the circuit to report voltages that don't exist, or prevent it from detecting voltages that do. Getting leakage low enough to allow accurage measurement of input voltage may be tricky, but getting it low enough that measurements when line voltage is present are noticeably different from those when it is absent should be much easier.
What is important when experimenting with any of this is that the portion that connects to the AC line through the safety-rated capacitors be constructed in such a way that it can not fail dangerously. Have insulated wires from the mains strain-relieved and restrained on the inside of an insulating box, then go through securely-mounted capacitors, and then exit through a strain-relieved set of "low voltage" wires which are restrained from going anywhere near the mains wires.
You may or may not find that you have the skill needed to usefully employ a setup like the above, but if you focus on ensuring that it is constructed in such a way that can not fail dangerously, the worst that might happen will be that you will waste time building a useless circuit.