clickio

elprogreso.es mobile and desktop sticky in passback

Dec 2nd, 2020
712
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- code for mobile sticky passback -->
  2. <script>
  3. var parentWindow = window.parent;
  4. parentWindow.postMessage("cl_enable_mobile_sticky", "*");
  5. </script>
  6.  
  7.  
  8. <!-- code for desktop sticky passback -->
  9. <script>
  10. var parentWindow = window.parent;
  11. parentWindow.postMessage("cl_enable_desktop_sticky", "*");
  12. </script>
  13.  
  14.  
  15. <!-- code for body -->
  16. <script>
  17. function showCode(parentSelector, parentWindow, code, divId) {
  18.   var s = document.currentScript;
  19.   var div = document.createElement('div');
  20.   if (divId) div.id = divId;
  21.   var divForScripts = document.createElement('div');
  22.   divForScripts.innerHTML = code;
  23.   div.appendChild(divForScripts);
  24.   var p = parentWindow.document.querySelector(parentSelector);
  25.   p.appendChild(div);
  26.   var scripts = divForScripts.getElementsByTagName("script");
  27.   Array.from(scripts).forEach(function(script, index, array) {
  28.     var newScript = document.createElement('script');
  29.     if(script !== s)
  30.     {
  31.       if(typeof script.src !== "undefined" && script.src && script.sr !== "")
  32.      {
  33.        newScript.src = script.src;
  34.         newScript.className = script.className;
  35.         div.appendChild(newScript);
  36.       }
  37.       else
  38.       {
  39.         var data = (script.text || script.textContent || script.innerHTML || "");
  40.         newScript.className = script.className;
  41.         newScript.type = script.type;
  42.         newScript.appendChild(document.createTextNode(data));
  43.         div.appendChild(newScript);
  44.       }
  45.       divForScripts.removeChild(script);
  46.     }
  47.   });
  48.   div.removeChild(divForScripts);
  49. }
  50.  
  51. function clAddMobileSticky() {
  52.   var adUnitCode = "<scr" + "ipt async type='text/javascript' src='//s.clickiocdn.com/t/common_258.js'><\/scr" + "ipt>" +
  53.     "<scr" + "ipt class='__lxGc__' type='text/javascript'>" +
  54.     "((__lxGc__=window.__lxGc__||{'s':{},'b':0})['s']['_218537']=__lxGc__['s']['_218537']||{'b':{}})['b']['_660209']={'i':__lxGc__.b++};" +
  55.     "<\/scr" + "ipt>";
  56.   showCode('body', window, adUnitCode, 'cl_adunit_wrapper');
  57. };
  58.  
  59. function clAddDesktopSticky() {
  60.   var adUnitCode = "<scr" + "ipt async type='text/javascript' src='//s.clickiocdn.com/t/common_258.js'><\/scr" + "ipt>" +
  61.     "<scr" + "ipt class='__lxGc__' type='text/javascript'>" +
  62.     "((__lxGc__=window.__lxGc__||{'s':{},'b':0})['s']['_218537']=__lxGc__['s']['_218537']||{'b':{}})['b']['_663008']={'i':__lxGc__.b++};" +
  63.     "<\/scr" + "ipt>";
  64.   showCode('body', window, adUnitCode, 'cl_adunit_wrapper');
  65. };
  66.  
  67. function receiveMessage(event)
  68. {
  69.   if (event.data == "cl_enable_mobile_sticky")
  70.     clAddMobileSticky();
  71.   if (event.data == "cl_enable_desktop_sticky")
  72.     clAddDesktopSticky();
  73. }
  74. window.addEventListener("message", receiveMessage, false);
  75.  
  76. </script>
RAW Paste Data