Guest User

Interstitial JS - ForoBeta

a guest
Dec 9th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Version 2 - 10/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. var MaxI = 2;
  8.  
  9. if(CualD!=3 && cantidadI<MaxI){
  10.     loadJSON();
  11. };
  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{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{font-family:'Open Sans',Verdana;}.clase0{z-index:2147483647;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:2147483647;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>";
  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>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>";
  19.     document.body.innerHTML += css + info;
  20.  
  21.     if(CualD=="1"){
  22.         document.getElementsByClassName("clase0")[0].className = "clase1";
  23.     };
  24.  
  25.     document.getElementsByClassName("alerta")[0].addEventListener('click', function () {
  26.         SacarScroll(false);
  27.         MeterCookie(1000);
  28.                 top.location.href = a;
  29.     }, false);
  30. };
  31.  
  32. function CerrarX(){
  33.     SacarScroll(false);
  34.     document.getElementsByClassName("fondo")[0].style.display = "none";
  35.     document.getElementsByClassName("alerta")[0].style.display = "none";
  36.     document.getElementsByClassName("barrita")[0].style.display = "none";
  37. };
  38.  
  39. function SacarScroll(n) {
  40.  if (n) {
  41.     html.style['overflow'] = 'hidden';
  42.     html.style['width'] = '100%';
  43.     html.style['height'] = '100%';
  44.     html.style['max-height'] = '100%';
  45.     html.style['position'] = 'fixed';
  46.     html.style['top'] = '0';
  47.     html.style['left'] = '0';
  48.  } else {
  49.     html.style['overflow'] = 'initial';
  50.     html.style['height'] = 'auto';
  51.     html.style['width'] = 'auto';
  52.     html.style['position'] = 'static';
  53.     html.style['max-height'] = 'initial';
  54.  };
  55. };
  56.  
  57. function DameCookie(cname) {
  58.     var name = cname + "=";
  59.     var ca = document.cookie.split(';');
  60.     for(var i = 0; i <ca.length; i++) {
  61.         var c = ca[i];
  62.         while (c.charAt(0)==' ') {
  63.             c = c.substring(1);
  64.         };
  65.         if (c.indexOf(name) == 0) {
  66.             return c.substring(name.length,c.length);
  67.         };
  68.     };
  69.     return "";
  70. };
  71.  
  72. function setVP() {
  73.     meta.name = 'viewport';
  74.     meta.content = 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no';
  75.     if (viewport) {
  76.         viewport.parentNode.removeChild(viewport);
  77.     };
  78.     document.head.appendChild(meta);
  79. };
  80.  
  81. function VerCualDisp(){
  82.     var t=navigator.userAgent||navigator.vendor||window.opera;
  83.     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";
  84.  
  85.     if(cual=="iOS") return 1;
  86.     if(cual=="Android") return 2;
  87.  
  88.     return 3;
  89. };
  90.  
  91. function VerCualID(){
  92.     var iOS_ID = "ACA_ID_IOS";
  93.     var Android_ID = "ACA_ID_ANDROID";
  94.  
  95.     if(CualD=="1") return iOS_ID;
  96.     if(CualD=="2") return Android_ID;
  97.  
  98.     return;
  99. };
  100.  
  101. function MeterCookie(cantidad){
  102.         var cad = new Date();
  103.         cad['setTime'](cad['getTime']() + (24 * 60 * 60 * 1000));
  104.         var expira = '; expires=' + cad['toGMTString']();
  105.         document.cookie = 'nopINTER=' + cantidad + expira + ';path=/';
  106. };
  107.  
  108. function loadJSON() {
  109.     var data_file = "https://admin.appnext.com/offerWallApi.aspx?pimp=1&tid=API&id="+VerCualID()+"&cnt=10";
  110.     var http_request = new XMLHttpRequest();
  111.     try {
  112.         http_request = new XMLHttpRequest();
  113.     } catch (e) {
  114.         try {
  115.             http_request = new ActiveXObject("Msxml2.XMLHTTP");
  116.         } catch (e) {
  117.             try {
  118.                 http_request = new ActiveXObject("Microsoft.XMLHTTP");
  119.             } catch (e) {
  120.                 return false;
  121.             };
  122.         };
  123.     };
  124.     http_request.onreadystatechange = function() {
  125.         if (http_request.readyState == 4) {
  126.         if(http_request.responseText=="") return;
  127.             var jsonObj = JSON.parse(http_request.responseText);
  128.             if (jsonObj.apps.length > 0) {
  129.                 var entry = jsonObj.apps[Math.floor(Math.random() * jsonObj.apps.length)];
  130.  
  131.                 new Image().src = entry.pixelImp;
  132.         setVP();
  133.                 CargarInter(entry.urlApp,entry.title,entry.urlImg);
  134.             };
  135.         };
  136.     };
  137.     http_request.open("GET", data_file, true);
  138.     http_request.send();
  139. };
Advertisement
Add Comment
Please, Sign In to add comment