Advertisement
clickio

virtualbrest.by horisontal sticky 1 time in session

Jul 8th, 2020
1,328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.61 KB | None | 0 0
  1. <div id="lx_sticky_wrapper"></div>
  2. <script>
  3. (function(w){
  4.  
  5.     function getCookie(name) {
  6.         let matches = document.cookie.match(new RegExp(
  7.             "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
  8.         ));
  9.         return matches ? decodeURIComponent(matches[1]) : undefined;
  10.     }
  11.  
  12.     function setCookie(name, value, options = {}) {
  13.         if (options.expires instanceof Date) {
  14.             options.expires = options.expires.toUTCString();
  15.         }
  16.         let updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value);
  17.         for (let optionKey in options) {
  18.             updatedCookie += "; " + optionKey;
  19.             let optionValue = options[optionKey];
  20.             if (optionValue !== true) {
  21.                 updatedCookie += "=" + optionValue;
  22.             }
  23.         }
  24.         document.cookie = updatedCookie;
  25.     }
  26.  
  27.     function showCode(p, c) {
  28.         var div = document.createElement('div');
  29.         div.innerHTML = c;
  30.         p.appendChild(div);
  31.         while (div.firstChild) p.insertBefore(div.firstChild, div);
  32.         p.removeChild(div);
  33.         var scripts = p.getElementsByTagName("script");
  34.         Array.from(scripts).forEach(function(script, index, array) {
  35.             var newScript = document.createElement('script');
  36.             if(typeof script.src !== "undefined" && script.src && script.sr !== "")
  37.            {
  38.                newScript.src = script.src;
  39.                 newScript.className = script.className;
  40.                 p.appendChild(newScript);
  41.             }
  42.             else
  43.             {
  44.                 var data = (script.text || script.textContent || script.innerHTML || "");
  45.                 newScript.className = script.className;
  46.                 newScript.type = script.type;
  47.                 newScript.appendChild(document.createTextNode(data));
  48.                 p.appendChild(newScript);
  49.             }
  50.             p.removeChild(script);
  51.         });
  52.     }
  53.  
  54.  
  55.     if(!getCookie("lx_sticky_shown"))
  56.     {
  57.         var code = "<scr" + "ipt async type='text/javascript' src='//s.clickiocdn.com/t/common_258.js'><\/scr" + "ipt>" +
  58.             "<scr" + "ipt class='__lxGc__' type='text/javascript'>" +
  59.             "((__lxGc__=window.__lxGc__||{'s':{},'b':0})['s']['_209992']=__lxGc__['s']['_209992']||{'b':{}})['b']['_659149']={'i':__lxGc__.b++};" +
  60.             "<\/scr" + "ipt>";  // code to insert
  61.         var parent = document.querySelector("#lx_sticky_wrapper");
  62.         showCode(parent, code);
  63.         setCookie("lx_sticky_shown", 1, {secure: true, 'expires': 'session'})
  64.     }
  65. })(window);
  66. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement