Advertisement
clickio

Sticky shows 2 (two) times in 1 (one) day

Apr 23rd, 2020
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.17 KB | None | 0 0
  1. <script>
  2. (function(w){
  3.     var showTime = 1;
  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.     function setCookie(name, value, options = {}) {
  12.         if (options.expires instanceof Date) {
  13.             options.expires = options.expires.toUTCString();
  14.         }
  15.         let updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value);
  16.         for (let optionKey in options) {
  17.             updatedCookie += "; " + optionKey;
  18.             let optionValue = options[optionKey];
  19.             if (optionValue !== true) {
  20.                 updatedCookie += "=" + optionValue;
  21.             }
  22.         }
  23.         document.cookie = updatedCookie;
  24.     }
  25.     function showCode(p, c) {
  26.         var div = document.createElement('div');
  27.         div.innerHTML = c;
  28.         p.appendChild(div);
  29.         while (div.firstChild) p.insertBefore(div.firstChild, div);
  30.         p.removeChild(div);
  31.         var scripts = p.getElementsByTagName("script");
  32.         Array.from(scripts).forEach(function(script, index, array) {
  33.             var newScript = document.createElement('script');
  34.             if(typeof script.src !== "undefined" && script.src && script.sr !== "")
  35.           {
  36.               newScript.src = script.src;
  37.                 newScript.className = script.className;
  38.                 p.appendChild(newScript);
  39.             }
  40.             else
  41.             {
  42.                 var data = (script.text || script.textContent || script.innerHTML || "");
  43.                 newScript.className = script.className;
  44.                 newScript.type = script.type;
  45.                 newScript.appendChild(document.createTextNode(data));
  46.                 p.appendChild(newScript);
  47.             }
  48.             p.removeChild(script);
  49.         });
  50.     }
  51.     var c = getCookie("lx_sticky_shown")
  52.     if(!c || ( c && Number.parseInt(c, 10) < showTime ) )
  53.    {
  54.        var div = document.createElement("DIV");
  55.         div.id = "lx_sticky_wrapper";
  56.         var b = document.querySelector("body");
  57.         b.appendChild(div);
  58.         var code = "<script async type='text/javascript' src='//s.clickiocdn.com/t/common_258.js'><\/scr" + "ipt>" +
  59.             "<script class='__lxGc__' type='text/javascript'>" +
  60.             "((__lxGc__=window.__lxGc__||{'s':{},'b':0})['s']['_191291']=__lxGc__['s']['_191291']||{'b':{}})['b']['_661779']={'i':__lxGc__.b++};" +
  61.             "<\/scr" + "ipt>" +
  62.             "<script class='__lxGc__' type='text/javascript'>" +
  63.             "((__lxGc__=window.__lxGc__||{'s':{},'b':0})['s']['_191291']=__lxGc__['s']['_191291']||{'b':{}})['b']['_661777']={'i':__lxGc__.b++};" +
  64.             "<\/scr" + "ipt>";
  65.         var parent = document.querySelector("#lx_sticky_wrapper");
  66.         showCode(parent, code);
  67.         var date = new Date();
  68.         date.setDate(date.getDate() + 1);
  69.         date.setHours(0,0,0,0);
  70.         var cv = (c?Number.parseInt(c, 10):0) + 1;
  71.         setCookie("lx_sticky_shown", cv, {secure: true, expires: date});
  72.     }
  73. })(window);
  74. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement