moat.js (1351B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /** 8 * Bug 1713704 - Shim Moat ad tracker 9 * 10 * Sites such as Forbes may gate content behind Moat ads, resulting in 11 * breakage like black boxes where videos should be placed. This shim 12 * helps mitigate that breakage by allowing the placement to succeed. 13 */ 14 15 if (!window.moatPrebidAPI?.__A) { 16 const targeting = new Map(); 17 18 const slotConfig = { 19 m_categories: ["moat_safe"], 20 m_data: "0", 21 m_safety: "safe", 22 }; 23 24 window.moatPrebidApi = { 25 __A() {}, 26 disableLogging() {}, 27 enableLogging() {}, 28 getMoatTargetingForPage: () => slotConfig, 29 getMoatTargetingForSlot(slot) { 30 return targeting.get(slot?.getSlotElementId()); 31 }, 32 pageDataAvailable: () => true, 33 safetyDataAvailable: () => true, 34 setMoatTargetingForAllSlots() { 35 for (const slot of window.googletag.pubads().getSlots() || []) { 36 targeting.set(slot.getSlotElementId(), slot.getTargeting()); 37 } 38 }, 39 setMoatTargetingForSlot(slot) { 40 targeting.set(slot?.getSlotElementId(), slotConfig); 41 }, 42 slotDataAvailable() { 43 return window.googletag?.pubads().getSlots().length > 0; 44 }, 45 }; 46 }