livechatinc

Loading livechat groups based on IP of the visitor

Sep 11th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <html>
  3.     <head>
  4.     <script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
  5.     </head>
  6.    
  7.     <body>
  8.    
  9.       <script>
  10.       var invokeLiveChat = function() {
  11.         var lc = document.createElement('script'); lc.type = 'text/javascript'; lc.async = true;
  12.         lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';
  13.         var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(lc, s);
  14.       }
  15.       var IPCheck = {    
  16.               getIP: function() {
  17.                
  18.                       if (/2.+/.test(geoplugin_status())) {
  19.                             var clientIP = geoplugin_request();
  20.                            
  21.                             return clientIP;
  22.                            }
  23.                       else {
  24.                               return false;
  25.                            }
  26.               }
  27.       };
  28.      
  29.       var arrayOfIPAddresses = ["194.181.146.133","194.181.146.132","194.181.146.131"];
  30.  
  31.       var ip = IPCheck.getIP();
  32.      
  33.       if(-1 < arrayOfIPAddresses.indexOf(ip))
  34.       {
  35.           console.log('bonzai!');
  36.           window.__lc = window.__lc || {};
  37.           window.__lc.license = LICENSE_NUMBER;
  38.           window.__lc.group = 1;
  39.           invokeLiveChat();
  40.       } else {
  41.         window.__lc = window.__lc || {};
  42.         window.__lc.license = LICENSE_NUMBER;
  43.         window.__lc.group = 2;
  44.           invokeLiveChat();
  45.       }
  46.       </script>
  47.    
  48.     </body>
  49.    
  50.    
  51.     </html>
Add Comment
Please, Sign In to add comment