Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3.   <head>
  4.     <meta charset="utf-8">
  5.     <title></title>
  6.     <script type="text/javascript">
  7.       // COUNTRY CODES: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
  8.       var country_urls = {
  9.         'US':'http://google.us',
  10.         'AU':'http://google.au',
  11.       };
  12.  
  13.       var URL_ERRORS = 'https://errodomain.example';
  14.       var URL_DEFAULT = 'https://defaultdomain.example';
  15.  
  16.       var xmlhttp = new XMLHttpRequest();
  17.     setTimeout(function() {
  18.         xmlhttp.onreadystatechange = function() {
  19.         if (this.readyState == 4 && this.status == 200) {
  20.           var res = this.responseText.split(";");
  21.  
  22.           if (res[0] === "1") {
  23.             if (res[1] in country_urls) {
  24.               top.location = country_urls[res[1]];
  25.             } else {
  26.               top.location = URL_DEFAULT;
  27.             }
  28.           } else {
  29.             top.location = URL_ERRORS;
  30.           }
  31.         }
  32.       };
  33.  
  34.     }, 1000);  
  35.      
  36.       xmlhttp.open("GET", "https://ip2c.org/self", true);
  37.       xmlhttp.send();
  38.     </script>
  39.   </head>
  40.   <body>
  41.   </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement