Advertisement
cicklow

v6 - ForoBeta Interstitial

Dec 10th, 2016
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* V6 - 02/01/2017 */
  2. /* FIX CSS */
  3. var CualD = VerCualDisp();
  4. var viewport = document.querySelector('meta[name="viewport"]');
  5. var meta = document.createElement('meta');
  6. var html = document.getElementsByTagName('html')[0];
  7. var cantidadI = DameCookie("nopINTER");
  8. if(cantidadI<0) cantidadI = 0;
  9. var MaxI = 2;
  10. var cuantasEntro = 0;
  11. var TextoAlerta = "Te recomendamos esta aplicaci&oacute;n";
  12.  
  13. function CargarInter(a,b,c){
  14.     SacarScroll(true);
  15.     cantidadI++
  16.     MeterCookie(cantidadI);
  17.     var css = "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://fonts.googleapis.com/css?family=Open+Sans\" /><style>.barrita{font-family:'Open Sans';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 #ionofooter .vacio{color: #eeeeee;}.clase0 img{width:30px;height:30px;border-radius:5px;margin:4px 0px 0px 5%;float:left}.clase0 #ionoheader{font-weight:bold;color:#3c3c3c;padding:10px 0px 0px 5%}.clase0 #ionoarticle{font-weight:500;margin:4px 5% 0px 5%;font-size:14px;color:#3c3c3c}.clase0 #ionofooter{float:left;width:100%;text-align:right;margin-bottom:10px;}.clase0 #ionofooter .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 #ionofooter{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 #ionoheader{font-weight:bold;color:#4f4f4f;width:100%;text-align:center;padding-top:10px}.clase1 #ionoarticle{width:100%;text-align:center;font-size:14px;color:#3c3c3c}.clase1 #ionofooter{margin-bottom:10px;width:100%;text-align:center;border-top:solid 1px #dcdcdc}.clase1 #ionofooter .vacio{display:none;}.clase1 #ionofooter .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 #ionofooter{margin-bottom:10px;margin-left:0px}}</style>";
  18.     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>"+TextoAlerta+"</article>      <img src=\""+c+"\">     <span class=\"nombreAPP\">"+b+"</span>      <footer><span class=\"boton\">OK</span></footer>    </div></div><div class=\"fondo\"></div>";
  19.  
  20.     if(document.body != null){
  21.         document.body.innerHTML += css + info;
  22.         if(CualD=="1"){
  23.             document.getElementsByClassName("clase0")[0].className = "clase1";
  24.         };
  25.  
  26.         document.getElementsByClassName("alerta")[0].addEventListener('click', function () {
  27.             CerrarX();
  28.             MeterCookie(1000);
  29.                     top.location.href = a;
  30.         }, false);
  31.     }else{
  32.         if(cuantasEntro<=2){
  33.             cuantasEntro++;
  34.             console.log('Entro con el timer ' + cuantasEntro);
  35.             setTimeout(function(){ CargarInter(a,b,c); }, 3000);
  36.         }
  37.     };
  38. };
  39.  
  40. function CerrarX(){
  41.     SacarScroll(false);
  42.     document.getElementsByClassName("fondo")[0].style.display = "none";
  43.     document.getElementsByClassName("alerta")[0].style.display = "none";
  44.     document.getElementsByClassName("barrita")[0].style.display = "none";
  45. };
  46.  
  47. function SacarScroll(n) {
  48.  if (n) {
  49.     html.style['overflow'] = 'hidden';
  50.     html.style['width'] = '100%';
  51.     html.style['height'] = '100%';
  52.     html.style['max-height'] = '100%';
  53.     html.style['position'] = 'fixed';
  54.     html.style['top'] = '0';
  55.     html.style['left'] = '0';
  56.  } else {
  57.     html.style['overflow'] = 'initial';
  58.     html.style['height'] = 'auto';
  59.     html.style['width'] = 'auto';
  60.     html.style['position'] = 'static';
  61.     html.style['max-height'] = 'initial';
  62.  };
  63. };
  64.  
  65. function DameCookie(cname) {
  66.     var name = cname + "=";
  67.     var ca = document.cookie.split(';');
  68.     for(var i = 0; i <ca.length; i++) {
  69.         var c = ca[i];
  70.         while (c.charAt(0)==' ') {
  71.             c = c.substring(1);
  72.         };
  73.         if (c.indexOf(name) == 0) {
  74.             return c.substring(name.length,c.length);
  75.         };
  76.     };
  77.     return "";
  78. };
  79.  
  80. function setVP() {
  81.     meta.name = 'viewport';
  82.     meta.content = 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no';
  83.     if (viewport) {
  84.         viewport.parentNode.removeChild(viewport);
  85.     };
  86.     document.head.appendChild(meta);
  87. };
  88.  
  89. function VerCualDisp(){
  90.     var t=navigator.userAgent||navigator.vendor||window.opera;
  91.     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";
  92.  
  93.     if(cual=="iOS") return 1;
  94.     if(cual=="Android") return 2;
  95.  
  96.     return 3;
  97. };
  98.  
  99. function VerCualID(){
  100.     var iOS_ID = "ACA_ID_IOS";
  101.     var Android_ID = "ACA_ID_ANDROID";
  102.  
  103.     if(CualD=="1") return iOS_ID;
  104.     if(CualD=="2") return Android_ID;
  105.  
  106.     return;
  107. };
  108.  
  109. function MeterCookie(cantidad){
  110.         var cad = new Date();
  111.         cad['setTime'](cad['getTime']() + (24 * 60 * 60 * 1000));
  112.         var expira = '; expires=' + cad['toGMTString']();
  113.         document.cookie = 'nopINTER=' + cantidad + expira + ';path=/';
  114. };
  115.  
  116. function loadJSON() {
  117.     var data_file = "https://admin.appnext.com/offerWallApi.aspx?pimp=1&tid=API&id="+VerCualID()+"&cnt=10";
  118.     var http_request = new XMLHttpRequest();
  119.     try {
  120.         http_request = new XMLHttpRequest();
  121.     } catch (e) {
  122.         try {
  123.             http_request = new ActiveXObject("Msxml2.XMLHTTP");
  124.         } catch (e) {
  125.             try {
  126.                 http_request = new ActiveXObject("Microsoft.XMLHTTP");
  127.             } catch (e) {
  128.                 return false;
  129.             };
  130.         };
  131.     };
  132.     http_request.onreadystatechange = function() {
  133.         if (http_request.readyState == 4) {
  134.         if(http_request.responseText=="") return;
  135.             var jsonObj = JSON.parse(http_request.responseText);
  136.             if (jsonObj.apps.length > 0) {
  137.                 var entry = jsonObj.apps[Math.floor(Math.random() * jsonObj.apps.length)];
  138.  
  139.                 new Image().src = entry.pixelImp;
  140.         setVP();
  141.                 CargarInter(entry.urlApp,entry.title,entry.urlImg);
  142.             };
  143.         };
  144.     };
  145.     http_request.open("GET", data_file, true);
  146.     http_request.send();
  147. };
  148.  
  149. document.addEventListener('DOMContentLoaded', function () {
  150.     if(CualD!=3 && cantidadI<=MaxI){
  151.         loadJSON();
  152.     };
  153. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement