Minimal JavaScript library to check if your visitors are TOR users
You are NOT using TOR
Visiting the NYTimes via the TOR browser it annoyed me, that they are not automatically redirecting me to their .onion service.
With this small library anyone could easily do that or provide other special functionalities for TOR users.
My server script generates the isTor global variable by checking the requesting IP against the TOR exit nodes list.
If you don't know that yet. The TOR browser is a privacy protecting web browser defending you against tracking and surveillance and helps to circumvent censorship.
<script src="https://simon-frey.eu/torjs/tor.js"></script>
<script> if(isTor){ alert("Hello World TOR user"); }else{ alert("Hello World normal user"); } </script>
<script> redirectTOR("snaajk2n2n2n2nakjnasdf.onion"); </script>
<script> executeForTOR(function () { alert("Hello World TOR user"); }); </script>
<script> executeForTOR(function () { alert("Hello World normal user"); }); </script>
This project is Public Domain and can be found on Github