// Some code that needs to run even if we dont run the Google ad codes var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; window['adLazyLoadQueue'] = []; var sAdSupplier = 'ezoic'; var bDelayAds = false; var sStartSrc = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js'; window.fLoadGoogleAds = function() { // Constants var AD_UNITS_CONFIG = getConfig(); var BIDDER_ALIASES = getBidderAliases(); var DISABLED_AD_UNITS = JSON.parse('["div-gpt-ad-1579280901640-0","div-gpt-ad-1579281349230-0"]'); var BIDDER_SETTINGS = JSON.parse('[]'); var PREBID_TIMEOUT = 1000; var MAX_RETRIES = 20; var LAZY_LOAD_AD_UNIT_MARGIN = 0; // Init namespaces var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; pbjs.retries = 0; // Export window.googletag = googletag; window.pbjs = pbjs; // Disable load until bids arrive googletag.cmd.push(function() { googletag.pubads().disableInitialLoad(); }); function getConfig() { return JSON.parse('[{"code":"div-gpt-ad-1579280679906-0","sizes":[[728,90]],"mediaTypes":{"banner":{"sizes":[[728,90]]}},"tracking_id":"\/21882844027\/Desktop-Zone1","bids":[{"bidder":"pubmatic","params":{"publisherId":"158936","adSlot":"MediaFire_Zone1"}},{"bidder":"sharethrough","params":{"pkey":"FFhNwGzXbCn2UmE6JFkHqMdk"},"labelAny":["GEO-BD","GEO-BR","GEO-EC","GEO-HN","GEO-NZ","GEO-PE"]},{"bidder":"medianet","params":{"cid":"8CUO2689O","crid":"557354025"}},{"bidder":"triplelift","params":{"inventoryCode":"MediaFire_ROS_Zone_prebid"}}]},{"code":"div-gpt-ad-1579280773917-0","sizes":[[336,280],[300,250]],"mediaTypes":{"banner":{"sizes":[[336,280],[300,250]]}},"tracking_id":"\/21882844027\/Desktop-Zone2","bids":[{"bidder":"pubmatic","params":{"publisherId":"158936","adSlot":"MediaFire_Zone2"}},{"bidder":"sharethrough","params":{"pkey":"0ZJQ1pwkfsk1ac2dCrJLNUi5"},"labelAny":["GEO-BD","GEO-BR","GEO-EC","GEO-HN","GEO-NZ","GEO-PE"]},{"bidder":"medianet","params":{"cid":"8CUO2689O","crid":"330813575"}},{"bidder":"triplelift","params":{"inventoryCode":"MediaFire_ROS_Zone_prebid"}}]},{"code":"div-gpt-ad-1579280808862-0","sizes":[[336,280],[300,250]],"mediaTypes":{"banner":{"sizes":[[336,280],[300,250]]}},"tracking_id":"\/21882844027\/Desktop-Zone3","bids":[{"bidder":"pubmatic","params":{"publisherId":"158936","adSlot":"MediaFire_Zone3"}},{"bidder":"sharethrough","params":{"pkey":"ZA9Mb3e56ooKgCVuFwH8DvW2"},"labelAny":["GEO-BD","GEO-BR","GEO-EC","GEO-HN","GEO-NZ","GEO-PE"]},{"bidder":"medianet","params":{"cid":"8CUO2689O","crid":"183032171"}},{"bidder":"triplelift","params":{"inventoryCode":"MediaFire_ROS_Zone_prebid"}}]},{"code":"div-gpt-ad-1579280901640-0","sizes":[[728,90]],"mediaTypes":{"banner":{"sizes":[[728,90]]}},"tracking_id":"\/21882844027\/Desktop-Zone4","bids":[{"bidder":"pubmatic","params":{"publisherId":"158936","adSlot":"MediaFire_Zone4"}},{"bidder":"sharethrough","params":{"pkey":"g2NbbCD3K0yQxBFRilDB0LXd"},"labelAny":["GEO-BD","GEO-BR","GEO-EC","GEO-HN","GEO-NZ","GEO-PE"]},{"bidder":"medianet","params":{"cid":"8CUO2689O","crid":"640217438"}},{"bidder":"triplelift","params":{"inventoryCode":"MediaFire_ROS_Zone_prebid"}}]},{"code":"div-gpt-ad-1579281349230-0","sizes":[[728,90]],"mediaTypes":{"banner":{"sizes":[[728,90]]}},"tracking_id":"\/21882844027\/Desktop-Zone6","bids":[{"bidder":"pubmatic","params":{"publisherId":"158936","adSlot":"MediaFire_Zone6"}},{"bidder":"sharethrough","params":{"pkey":"g2NbbCD3K0yQxBFRilDB0LXd"},"labelAny":["GEO-BD","GEO-BR","GEO-EC","GEO-HN","GEO-NZ","GEO-PE"]},{"bidder":"medianet","params":{"cid":"8CUO2689O","crid":"284788225"}},{"bidder":"triplelift","params":{"inventoryCode":"MediaFire_ROS_Zone_prebid"}}]}]'); } function getBidderAliases() { return JSON.parse('[]'); } // Bids arrived or timeout reached function initAdserver() { if (pbjs.initAdserverSet) return; if (!googletag.pubadsReady && pbjs.retries <= MAX_RETRIES) { setTimeout(initAdserver, 50); pbjs.retries++; return; } pbjs.initAdserverSet = true; googletag.cmd.push(function() { pbjs.que.push(function() { pbjs.setTargetingForGPTAsync(); window.setMaxBidTargeting(); // This displays google ads window.displayGoogleAdUnits(); }); }); } // Load ad units except disabled ones window.displayGoogleAdUnits = function() { AD_UNITS_CONFIG.forEach(function(ad) { if (DISABLED_AD_UNITS.includes(ad.code)) return; window.refreshSlot(ad.code); }); }; // define public method to refresh a slot window.refreshSlot = function(code) { googletag.pubads().getSlots().some(function(slot) { if (slot.getSlotElementId() == code) { googletag.pubads().refresh([slot]); return true; } }); } // Find max bids and their bidders for each ad code // See https://docs.prebid.org/dev-docs/publisher-api-reference.html window.setMaxBidTargeting = function() { var maxBids = []; pbjs.adUnits.forEach(unit=>{ var topMaxBid = null; var topMaxBidStr; var topBidder ; pbjs.getBidResponsesForAdUnitCode(unit.code).bids.forEach(bid=>{ var fBidValue = parseFloat(bid.pbCg); if (topMaxBid == null || fBidValue > topMaxBid) { topMaxBid = fBidValue; topMaxBidStr = bid.pbCg; topBidder = bid.bidder; } }); maxBids[unit.code] = { bidder: topBidder, maxBid: topMaxBidStr }; }); googletag.pubads().getSlots().map(slot=>{ var adCode = slot.getSlotElementId(); slot .setTargeting('hb_highestbidder', maxBids[adCode].bidder) .setTargeting('hb_highestbid', maxBids[adCode].maxBid); }); } var adLoaded = []; window.checkAdUnitView = function(code, elementPosition, windowScrollData) { if (adLoaded[code]) { return; } if ((elementPosition.left - LAZY_LOAD_AD_UNIT_MARGIN) < windowScrollData.windowInnerWidth && (elementPosition.right + LAZY_LOAD_AD_UNIT_MARGIN) > 0 && (elementPosition.top - LAZY_LOAD_AD_UNIT_MARGIN) < windowScrollData.windowInnerHeight && (elementPosition.bottom + LAZY_LOAD_AD_UNIT_MARGIN) > 0) { googletag.cmd.push(function () { window.refreshSlot(code); adLoaded[code] = true; }); } } window.checkQueuedAdUnitViews = function(windowScrollData) { var queue = window['adLazyLoadQueue']; if (!queue.length) return; queue.forEach(function(code) { var adElement = document.getElementById(code); if (adElement) { var boundingRect = adElement.getBoundingClientRect(); window.checkAdUnitView(code, { left: boundingRect.left - windowScrollData.windowPageXOffset, right: boundingRect.left + boundingRect.width, top: boundingRect.top - windowScrollData.windowPageYOffset, bottom: boundingRect.top + boundingRect.height }, windowScrollData); } }); } // Helper function to load scripts function loadScript(src) { var script = document.createElement('script'); script.async = true; script.type = 'text/javascript'; script.src = src; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(script, node); } // Timeout if bids take x milliseconds setTimeout(initAdserver, PREBID_TIMEOUT); // Load Prebid /* Version: 8.10.0 Bidders: AppNexus OpenX Pubmatic Sharethrough Analytic Adapters: Modules: */ loadScript('/js/prebid8.10.0.js'); // Setup and request bids pbjs.que.push(function() { // For reference: // http://prebid.org/dev-docs/publisher-api-reference.html#module_pbjs.setConfig pbjs.setConfig({ debug: false, enableSendAllBids: true, priceGranularity: { buckets: [ { max: 0.05, increment: 0.01 }, { max: 5, increment: 0.05 }, { max: 10, increment: 0.10 }, { max: 20, increment: 0.50 } ] }, bidderSequence: 'random', bidderTimeout: PREBID_TIMEOUT, userSync: { filterSettings: { iframe: { bidders: '*', filter: 'include' } } } // cache: {url: "https://prebid.adnxs.com/pbc/v1/cache"}, // s2sConfig: { // endpoint: "https://prebid.adnxs.com/pbs/v1/openrtb2/auction", // syncEndpoint: "https://prebid.adnxs.com/pbs/v1/cookie_sync", // } }); BIDDER_ALIASES.forEach(function(bidderAlias) { pbjs.aliasBidder(bidderAlias.name, bidderAlias.alias); }); // Bidder settings for (bidder in BIDDER_SETTINGS) { if (BIDDER_SETTINGS[bidder].bidCpmAdjustment) { pbjs.bidderSettings[bidder] = pbjs.bidderSettings[bidder] || {}; pbjs.bidderSettings[bidder].bidCpmAdjustment = (function(bidCpmAdjustment, bidCpm, bid){ return bidCpm * bidCpmAdjustment / 100; }).bind(null, BIDDER_SETTINGS[bidder].bidCpmAdjustment); } } pbjs.addAdUnits(AD_UNITS_CONFIG); pbjs.requestBids({ bidsBackHandler: initAdserver, labels: ['GEO-NO'] }); }); // Define and enable ad slots googletag.cmd.push(function() { for (var i = 0; i < AD_UNITS_CONFIG.length; i++) { var slot; var ad; try { ad = AD_UNITS_CONFIG[i]; slot = googletag.defineSlot(ad.tracking_id, ad.sizes, ad.code); if (slot) { slot.addService(googletag.pubads()) .setTargeting('dkey_present', 'false') .setTargeting('buildnumber', '121918') .setTargeting('dladtemplate', '51') .setTargeting('button_delay', 'disabled'); } } catch (e) { console.log('ad failed: ', e, ad, slot); } } try { googletag.pubads().set('page_url', top.location.href); } catch(e) { googletag.pubads().set('page_url', 'https://www.mediafire.com'); } googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); if (bDelayAds) { // Delay Loading Google Services window.delayAdStartScript && window.delayAdStartScript(); } else { // Load Google Services loadScript('https://securepubads.g.doubleclick.net/tag/js/gpt.js'); } }; if (sAdSupplier === 'ezoic') { window.checkEzoicSplitResult = function() { if (window.bEzoicSelected === undefined) { setTimeout(window.checkEzoicSplitResult, 50); return; } if (window.bEzoicSelected) { if (bDelayAds) { window.startLazyLoad && window.startLazyLoad(); } } else { // This loads google ads // this is typically called when this event occurs but when exoic is in use, it may not be // called and instead be called later once ezoic selection has happened and we've determined // https://app.asana.com/0/1202116959041480/1204891726118085/f window.fLoadGoogleAds(); } }; window.checkEzoicSplitResult(); } else { window.fLoadGoogleAds(); }