Advertisement
clickio

magya-online.ru mobile * desktop sticky 1 time in 20 minutes

Dec 11th, 2020
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.48 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.     /* Desktop sticky */
  55.     if(!getCookie("lx_sticky_desktop_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']['_194050']=__lxGc__['s']['_194050']||{'b':{}})['b']['_664569']={'i':__lxGc__.b++};" +
  60.             "<\/scr" + "ipt>"; // code to insert
  61.  
  62.         var parent = document.querySelector("#lx_sticky_wrapper");
  63.         showCode(parent, code);
  64.  
  65.         var today = new Date();
  66.         today.setMinutes(today.getMinutes() + 20);
  67.         setCookie("lx_sticky_desktop_shown", 1, {secure: true, 'expires': today.toString()});
  68.     }
  69.  
  70.     /* Mobile sticky */
  71.     if(!getCookie("lx_sticky_mobile_shown"))
  72.     {
  73.         var code = "<scr" + "ipt async type='text/javascript' src='//s.clickiocdn.com/t/common_258.js'><\/scr" + "ipt>" +
  74.             "<scr" + "ipt class='__lxGc__' type='text/javascript'>" +
  75.             "((__lxGc__=window.__lxGc__||{'s':{},'b':0})['s']['_194050']=__lxGc__['s']['_194050']||{'b':{}})['b']['_664575']={'i':__lxGc__.b++};" +
  76.             "<\/scr" + "ipt>"; // code to insert
  77.  
  78.         var parent = document.querySelector("#lx_sticky_wrapper");
  79.         showCode(parent, code);
  80.  
  81.         var today = new Date();
  82.         today.setMinutes(today.getMinutes() + 20);
  83.         setCookie("lx_sticky_mobile_shown", 1, {secure: true, 'expires': today.toString()});
  84.     }
  85. })(window);
  86. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement