Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function(d,w){
- let adsSelectors = "[id^=MarketGid]";
- let screenTop = w.innerHeight*2;
- let screenBottom = w.innerHeight*3;
- let adInScreen = false;
- let ad = null;
- function checkPosition() {
- Array.from(d.querySelectorAll(adsSelectors)).forEach(function(adEl){
- let o = adEl.getBoundingClientRect();
- if(!adInScreen)
- {
- if((o.top >= screenTop && o.top <= screenBottom) || (o.bottom >= screenTop && o.bottom <= screenBottom))
- {
- adInScreen = true;
- }
- if(adInScreen){
- ad = {
- element: adEl,
- rect: o
- };
- }
- }
- });
- }
- function addContainer(cId, s, p) {
- let c = d.createElement('div');
- c.id = cId;
- let e = d.querySelector(s);
- if(e)
- {
- if (p && p === "top")
- {
- let ch = d.querySelector(s + " > :first-child");
- if(ch) e.insertBefore(c, ch)
- else e.appendChild(c); // Усли нет дочерних элементов - просто добавляем к родителю
- }
- else e.appendChild(c);
- }
- return c;
- }
- let t = d.querySelector('#mw-content-text');
- const c = {
- attributes: true,
- childList: true,
- subtree: true
- };
- const cb = function(mutationsList, observer) {
- for (let mutation of mutationsList) {
- if(mutation.type === "childList" && mutation.target.classList.contains("mgbox"))
- {
- checkPosition();
- }
- }
- };
- let o = new MutationObserver(cb);
- o.observe(t, c);
- let to = setTimeout(function() {
- if(!adInScreen){
- let cId = "clickio_smart";
- addContainer(cId, "body", "top");
- (w.__lxGc__=w.__lxGc__||{'s':{},'b':0}).cmd=w.__lxGc__.cmd||[];
- __lxGc__.cmd.push(function(){
- __lxGc__.display(cId, "_220206", "_676156");
- });
- o.disconnect()
- }
- }, 5000);
- })(document, window);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement