Advertisement
clickio

daz.wiki smart in 3rd screen when no other ads

Mar 3rd, 2021
940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. (function(d,w){
  3.     let adsSelectors = "[id^=MarketGid]";
  4.     let screenTop = w.innerHeight*2;
  5.     let screenBottom = w.innerHeight*3;
  6.     let adInScreen = false;
  7.     let ad = null;
  8.  
  9.     function checkPosition() {
  10.         Array.from(d.querySelectorAll(adsSelectors)).forEach(function(adEl){
  11.             let o = adEl.getBoundingClientRect();
  12.             if(!adInScreen)
  13.             {
  14.                 if((o.top >= screenTop && o.top <= screenBottom) || (o.bottom >= screenTop && o.bottom <= screenBottom))
  15.                 {
  16.                     adInScreen = true;
  17.                 }
  18.                 if(adInScreen){
  19.                     ad = {
  20.                         element: adEl,
  21.                         rect: o
  22.                     };
  23.                 }
  24.             }
  25.         });
  26.     }
  27.  
  28.     function addContainer(cId, s, p) {
  29.         let c = d.createElement('div');
  30.         c.id  = cId;
  31.         let e = d.querySelector(s);
  32.         if(e)
  33.         {
  34.             if (p && p === "top")
  35.             {
  36.                 let ch = d.querySelector(s + " > :first-child");
  37.                 if(ch) e.insertBefore(c, ch)
  38.                 else   e.appendChild(c); // Усли нет дочерних элементов - просто добавляем к родителю
  39.             }
  40.             else e.appendChild(c);
  41.         }
  42.         return c;
  43.     }
  44.  
  45.     let t = d.querySelector('#mw-content-text');
  46.     const c = {
  47.         attributes: true,
  48.         childList: true,
  49.         subtree: true
  50.     };
  51.     const cb = function(mutationsList, observer) {
  52.         for (let mutation of mutationsList) {
  53.             if(mutation.type === "childList" && mutation.target.classList.contains("mgbox"))
  54.             {
  55.                 checkPosition();
  56.             }
  57.         }
  58.     };
  59.     let o = new MutationObserver(cb);
  60.     o.observe(t, c);
  61.  
  62.     let to = setTimeout(function() {
  63.         if(!adInScreen){
  64.             let cId = "clickio_smart";
  65.             addContainer(cId, "body", "top");
  66.             (w.__lxGc__=w.__lxGc__||{'s':{},'b':0}).cmd=w.__lxGc__.cmd||[];
  67.             __lxGc__.cmd.push(function(){
  68.                 __lxGc__.display(cId, "_220206", "_676156");
  69.             });
  70.  
  71.             o.disconnect()
  72.         }
  73.     }, 5000);
  74. })(document, window);
  75. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement