apstag.js (1586B)
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 1713698 - Shim Amazon Transparent Ad Marketplace's apstag.js 9 * 10 * Some sites such as politico.com rely on Amazon TAM tracker to serve ads, 11 * breaking functionality like galleries if it is blocked. This shim helps 12 * mitigate major breakage in that case. 13 */ 14 15 if (!window.apstag?._getSlotIdToNameMapping) { 16 const _Q = window.apstag?._Q || []; 17 18 const newBid = config => { 19 return { 20 amznbid: "", 21 amzniid: "", 22 amznp: "", 23 amznsz: "0x0", 24 size: "0x0", 25 slotID: config.slotID, 26 }; 27 }; 28 29 window.apstag = { 30 _Q, 31 _getSlotIdToNameMapping() {}, 32 bids() {}, 33 debug() {}, 34 deleteId() {}, 35 fetchBids(cfg, cb) { 36 if (!Array.isArray(cfg?.slots)) { 37 return; 38 } 39 setTimeout(() => { 40 cb(cfg.slots.map(s => newBid(s))); 41 }, 1); 42 }, 43 init() {}, 44 punt() {}, 45 renderImp() {}, 46 renewId() {}, 47 setDisplayBids() {}, 48 targetingKeys: () => [], 49 thirdPartyData: {}, 50 updateId() {}, 51 }; 52 53 window.apstagLOADED = true; 54 55 _Q.push = function (prefix, args) { 56 try { 57 switch (prefix) { 58 case "f": 59 window.apstag.fetchBids(...args); 60 break; 61 case "i": 62 window.apstag.init(...args); 63 break; 64 } 65 } catch (e) { 66 console.trace(e); 67 } 68 }; 69 70 for (const cmd of _Q) { 71 _Q.push(cmd); 72 } 73 }