clickio

ridus.ru adfox dinamic policy

Dec 2nd, 2020 (edited)
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 6.58 KB | None | 0 0
  1. <script>
  2. (function(w,d){
  3.     w.__clADF__urlPull = {};
  4.     var counter =1;
  5.     var debug = true;
  6.    
  7.     function log(msg) {
  8.         if(debug) console.log(msg);
  9.     }
  10.     function forEach(array, callback, scope) {
  11.       for (var i = 0; i < array.length; i++) {
  12.        callback.call(scope, i, array[i]);
  13.      }
  14.    };
  15.    function addBanners(title){
  16.        log("addBanners init");
  17.        
  18.        var articles = document.querySelectorAll('.article__container');
  19.        if(articles.length)
  20.        {
  21.            forEach(articles, function (index, article) {
  22.                
  23.                var articleTitle = article.querySelector('.alasliderimage p').innerText.trim();
  24.                var content = article.querySelector('.typography');
  25.                var adUnitNode = content.querySelector('div[id^="adfox_"]');
  26.                if(articleTitle == title && !adUnitNode)
  27.                {
  28.                    log("addBanners adding banner with counter " + counter);
  29.                    var el = document.createElement('div');
  30.                    el.setAttribute("id", "adfox_154505042490062278-" + counter);
  31.                    el.setAttribute("style","margin-bottom:1em;");
  32.                    content.insertBefore(el, content.firstChild);
  33.                    (function() {
  34.                        (function(w, n) {
  35.                            w[n] = w[n] || [];
  36.                            w[n].push({
  37.                                ownerId: 262633,
  38.                                containerId: 'adfox_154505042490062278-' + counter,
  39.                                params: {
  40.                                    pp: 'old',
  41.                                    ps: 'dbuh',
  42.                                    p2: 'gbwp',
  43.                                    pk: __clADF__.state
  44.                                }
  45.                            });
  46.                        })(window, 'adfoxAsyncParams');
  47.                        counter++;
  48.                          
  49.                    }).call(this);
  50.                }
  51.            });
  52.        }
  53.    }
  54.    var getPolicy = function(href) {
  55.        log("getPolicy init");
  56.        var title = document.title;
  57.        var referer = document.referrer;
  58.        function a(ref) {
  59.            __clADF__.adxAllowed(0)
  60.        }
  61.        var b = window,
  62.            c = b.document,
  63.            d = c.getElementsByTagName('head')[0];
  64.        d || (d = c.createElement('head'), b.appendChild(d)), b.__clADF__ = {
  65.            state: 0,
  66.            loaded: 0,
  67.            adxAllowed: function(a) {
  68.                log(b.__clADF__);
  69.                if (1 != this.loaded) {
  70.                    log('getPolicy loaded = false');
  71.                    n = 'adfoxAsyncParams', b[n] && log(b[n]) && b[n].forEach(function(b) {
  72.                        b.params.pk = a
  73.                    }), n1 = n + 'Scroll', b[n1] && log(b[n1]) && b[n1].forEach(function(b) {
  74.                        b[0].params.pk = a
  75.                    }), n1 = n + 'Adaptive', b[n1] && log(b[n1]) && b[n1].forEach(function(b) {
  76.                        b[0].params.pk = a
  77.                    }), n = 'Adaptive', b[n] && log(b[n]) && b[n].forEach(function(b) {
  78.                        b[0].params.pk = a
  79.                    }), this.state = a;
  80.                    var s = c.querySelector('script[src="https://yastatic.net/pcode/adfox/loader.js"]');
  81.                    if(!s)
  82.                    {
  83.                        log("getPolicy adding loader");
  84.                        var d = c.createElement('script');
  85.                        d.setAttribute('src', 'https://yastatic.net/pcode/adfox/loader.js'), d.setAttribute('async', 'async');
  86.                        var e = c.getElementsByTagName('head')[0];
  87.                        e || (e = c.createElement('head'), b.appendChild(e)), e.appendChild(d);
  88.                    }
  89.                    else
  90.                    {
  91.                        log("getPolicy already got loader");
  92.                    }
  93.                    this.loaded = 1
  94.                    b.__clADF__urlPull[href] = b.__clADF__;
  95.                }
  96.                else
  97.                {
  98.                    var contents = document.querySelectorAll('.typography');
  99.                    if (contents.length)
  100.                    {
  101.                        addBanners(title);
  102.                    }
  103.                    log('getPolicy loaded = true');
  104.                }
  105.            }
  106.        };
  107.        if(!w.__clADF__urlPull[href])
  108.        {
  109.            log('getPolicy new __clADF__ for href: ' + href);
  110.            
  111.            var e = c.createElement('script');
  112.            e.setAttribute('src', '//clickiocdn.com/hbadx/?' +
  113.                'f=__clADF__&rt=' + new Date().getTime() +
  114.                '&site_id=218227&title=' + encodeURIComponent(title) +
  115.                '&r=' + encodeURIComponent(referer)),
  116.            e.setAttribute('async', 'async'),
  117.            e.onreadystatechange = e.onload = function()
  118.            {
  119.                log('getPolicy onreadystatechange for href: ' + href);
  120.                if('loaded' != this.readyState && 'complete' != this.readyState)
  121.                {
  122.                    log('getPolicy not loaded for href: ' + href);
  123.                    setTimeout(function(){
  124.                        a(title);
  125.                    }, 0);
  126.                }
  127.                else
  128.                {
  129.                    log('getPolicy loaded for href: ' + href);
  130.                }
  131.            },
  132.            e.onerror = function()
  133.            {
  134.                log('getPolicy onerror for href: ' + href);
  135.                setTimeout(a, 0)
  136.            }, d.appendChild(e), setTimeout(a, 3e3)
  137.            
  138.        }
  139.        else {
  140.            log('getPolicy already have __clADF__ for href: ' + href);
  141.            w.__clADF__ = w.__clADF__urlPull[href];
  142.        }
  143.    };
  144.    getPolicy(document.location.href);
  145.    var oldHref = document.location.href;
  146.    window.onload = function() {
  147.        var bodyList = document.querySelector("body"),
  148.            observer = new MutationObserver(function(mutations) {
  149.                mutations.forEach(function(mutation) {
  150.                    if (oldHref != document.location.href) {
  151.                        oldHref = document.location.href;
  152.                        log("LOCATION IS:", document.location.href);
  153.                        getPolicy(document.location.href);
  154.                    }
  155.                });
  156.            });
  157.        var config = {
  158.            childList: true,
  159.            subtree: true
  160.        };
  161.        observer.observe(bodyList, config);
  162.    };
  163. })(window, document);
  164. </script>
Add Comment
Please, Sign In to add comment