Guest User

Interstitial JS - ForoBeta

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