cicklow

CPALead Interestitial - ForoBeta

Dec 12th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* V5 (CPALead) - 19/12/2016 */
  2. var CualD = VerCualDisp();
  3. var viewport = document.querySelector('meta[name="viewport"]');
  4. var meta = document.createElement('meta');
  5. var html = document.getElementsByTagName('html')[0];
  6. var cantidadI = DameCookie("nopINTER");
  7. if(cantidadI<0) cantidadI = 0;
  8. var MaxI = 12;
  9. var QueMostrar = "ALL";
  10. var cuantasEntro = 0;
  11.  
  12. function CargarInter(a,b,c,d){
  13.     SacarScroll(true);
  14.     cantidadI++
  15.     MeterCookie(cantidadI);
  16.     var css = "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://fonts.googleapis.com/css?family=Open+Sans\" /><style>.barrita{background-color:#eeeeee;height:25px;text-align:right;width:100%;position:absolute;top:0px;left:0px;z-index:2147483647;}.barrita a{font-family:'Open Sans';font-size:13px;padding:5px;text-decoration:none;color:#000}.fondo{z-index:147483600;position:fixed;background-color:#000;top:0px;left:0px;width:100%;height:100%;opacity:0.5;filter:alpha(opacity=50)}.alerta{width: 100%;height: 100%;position: fixed;top: 0px;left: 0px;z-index: 2147483640;font-family:'Open Sans',Verdana;}.clase0{z-index:2147483640;border-radius:3px;background:#eeeeee;width:90%;margin:auto;position:absolute;left:0;right:0;top:30%;border:1px solid #fff}.clase0 img{width:30px;height:30px;border-radius:5px;margin:4px 0px 0px 5%;float:left}.clase0 header{font-weight:bold;color:#3c3c3c;padding:10px 0px 0px 5%}.clase0 article{font-weight:500;margin:4px 5% 0px 5%;font-size:14px;color:#3c3c3c}.clase0 footer{float:left;width:100%;text-align:right;margin-bottom:10px;margin-left:-10px}.clase0 footer .boton{font-size:14px;color:#009688;font-weight:bold;margin:2%}.clase0 .nombreAPP{font-size:14px;float:left;font-weight:bold;color:#3c3c3c;margin:10px 0px 0px 1%;padding:0px}@media only screen and (min-width: 768px){.clase0 footer{margin-bottom:10px;margin-left:0px}}.clase1{z-index:2147483640;border-radius:8px;background:#e6e6e6;width:90%;margin:auto;position:absolute;left:0;right:0;top:30%;border:1px solid #fff}.clase1 img{width:30px;height:30px;border-radius:5px;margin:4px 0px 8px 5%;vertical-align:middle}.clase1 header{font-weight:bold;color:#4f4f4f;width:100%;text-align:center;padding-top:10px}.clase1 article{width:100%;text-align:center;font-size:14px;color:#3c3c3c}.clase1 footer{margin-bottom:10px;width:100%;text-align:center;border-top:solid 1px #dcdcdc}.clase1 footer .boton{font-size:14px;color:#6dacf3;font-weight:bold;padding:15px}.clase1 .nombreAPP{font-size:14px;font-weight:bold;color:#3c3c3c}@media only screen and (min-width: 768px){.clase1 footer{margin-bottom:10px;margin-left:0px}}</style>";
  17.     var info = "<div class=\"barrita\"><a href=\"javascript:void(0);\" onclick=\"CerrarX();\">x</a></div><div class=\"alerta\"> <div class=\"clase0\">      <header>Alerta</header>     <article>Para ver el contenido es necesario instalar esta aplicacion</article>      <img src=\""+c+"\">     <span class=\"nombreAPP\">"+b+"</span>      <footer><span class=\"boton\">OK</span></footer>    </div></div><div class=\"fondo\"></div>";
  18.  
  19.     if(document.body != null){
  20.         document.body.innerHTML += css + info;
  21.         if(CualD=="1"){
  22.             document.getElementsByClassName("clase0")[0].className = "clase1";
  23.         };
  24.  
  25.         document.getElementsByClassName("alerta")[0].addEventListener('click', function () {
  26.             CerrarX();
  27.             MeterCookie(1000);
  28.             if(d){ CerrarX(); window.open(a,'_blank'); }else{ top.location.href = a; }
  29.         }, false);
  30.     }else{
  31.         if(cuantasEntro<=2){
  32.             cuantasEntro++;
  33.             console.log('Entro con el timer ' + cuantasEntro);
  34.             setTimeout(function(){ CargarInter(a,b,c); }, 3000);
  35.         }
  36.     };
  37. };
  38.  
  39. function CerrarX(){
  40.     SacarScroll(false);
  41.     document.getElementsByClassName("fondo")[0].style.display = "none";
  42.     document.getElementsByClassName("alerta")[0].style.display = "none";
  43.     document.getElementsByClassName("barrita")[0].style.display = "none";
  44. };
  45.  
  46. function SacarScroll(n) {
  47.  if (n) {
  48.     html.style['overflow'] = 'hidden';
  49.     html.style['width'] = '100%';
  50.     html.style['height'] = '100%';
  51.     html.style['max-height'] = '100%';
  52.     html.style['position'] = 'fixed';
  53.     html.style['top'] = '0';
  54.     html.style['left'] = '0';
  55.  } else {
  56.     html.style['overflow'] = 'initial';
  57.     html.style['height'] = 'auto';
  58.     html.style['width'] = 'auto';
  59.     html.style['position'] = 'static';
  60.     html.style['max-height'] = 'initial';
  61.  };
  62. };
  63.  
  64. function DameCookie(cname) {
  65.     var name = cname + "=";
  66.     var ca = document.cookie.split(';');
  67.     for(var i = 0; i <ca.length; i++) {
  68.         var c = ca[i];
  69.         while (c.charAt(0)==' ') {
  70.             c = c.substring(1);
  71.         };
  72.         if (c.indexOf(name) == 0) {
  73.             return c.substring(name.length,c.length);
  74.         };
  75.     };
  76.     return "";
  77. };
  78.  
  79. function setVP() {
  80.     meta.name = 'viewport';
  81.     meta.content = 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no';
  82.     if (viewport) {
  83.         viewport.parentNode.removeChild(viewport);
  84.     };
  85.     document.head.appendChild(meta);
  86. };
  87.  
  88. function MeterCookie(cantidad){
  89.         var cad = new Date();
  90.         cad['setTime'](cad['getTime']() + (24 * 60 * 60 * 1000));
  91.         var expira = '; expires=' + cad['toGMTString']();
  92.         document.cookie = 'nopINTER=' + cantidad + expira + ';path=/';
  93. };
  94.  
  95. function loadJSON() {
  96.     var ID_USER = "ACA_ID_CPALEAD";
  97.     var script = document.createElement('script');
  98.     script.src = "https://www.cpalead.com/dashboard/reports/campaign_json_load_offers.php?id="+ID_USER+"&format=json&geoip=user&show=10&offer_type=mobile&ua=user&format=JSONP&callback=SacarDatos";
  99.     document.getElementsByTagName('head')[0].appendChild(script);
  100. };
  101.  
  102. function VerCualDisp(){
  103.     var t=navigator.userAgent||navigator.vendor||window.opera;
  104.     var cual = t.match(/Opera Mini/i)||t.match(/Windows/i)?"unknown":t.match(/iPad/i)||t.match(/iPhone/i)||t.match(/iPod/i)||t.match(/iOS/i)?"iOS":t.match(/Android/i)?"Android":"unknown";
  105.  
  106.     if(cual=="iOS") return "ios";
  107.     if(cual=="Android") return "android";
  108.  
  109.     return 3;
  110. };
  111.  
  112. var CantidadVueltas = 0;
  113.  
  114. function SacarDatos(data){
  115.     CantidadVueltas++;
  116.     if(CantidadVueltas>3) return;
  117.  
  118.     var popono = false;
  119.     var imgicon = "http://icons.iconarchive.com/icons/custom-icon-design/flatastic-1/64/alert-icon.png";
  120.     var titulo  = "";
  121.     var jsonObj = data;
  122.     if (jsonObj.offers.length > 0) {
  123.         var entry = jsonObj.offers[Math.floor(Math.random() * jsonObj.offers.length)];
  124.         console.log("entry.mobile_app_type = " + entry.mobile_app_type);
  125.         if(QueMostrar=="CPI"){
  126.             if(VerCualDisp() != entry.mobile_app_type){ SacarDatos(data); };
  127.         }else{
  128.             if(entry.mobile_app_type != null){ if(VerCualDisp() != entry.mobile_app_type){ SacarDatos(data); }; };
  129.         };
  130.  
  131.         if(entry.mobile_app_type != null){ popono = false; }else{ popono = true; }
  132.  
  133.         setVP();
  134.         if(entry.mobile_app_icon_url != null) imgicon = entry.mobile_app_icon_url;
  135.         titulo = entry.title.split("-");
  136.         if(titulo[0] != null){ titulo = titulo[0]; }else{ titulo = entry.title; };
  137.                 CargarInter(entry.link,titulo,imgicon,popono);
  138.     };
  139. };
  140.  
  141. document.addEventListener('DOMContentLoaded', function () {
  142.     if(CualD!=3 && cantidadI<=MaxI){
  143.         loadJSON();
  144.     };
  145. });
Advertisement
Add Comment
Please, Sign In to add comment