@@ -20,6 +20,7 @@ export let allowAuction;
20
20
export let staticConsentData ;
21
21
22
22
let consentData ;
23
+ let addedConsentHook = false ;
23
24
24
25
// add new CMPs here, with their dedicated lookup function
25
26
const cmpCallMap = {
@@ -56,11 +57,11 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
56
57
}
57
58
58
59
return {
59
- consentDataCallback : function ( consentResponse ) {
60
+ consentDataCallback : function ( consentResponse ) {
60
61
cmpResponse . getConsentData = consentResponse ;
61
62
afterEach ( ) ;
62
63
} ,
63
- vendorConsentsCallback : function ( consentResponse ) {
64
+ vendorConsentsCallback : function ( consentResponse ) {
64
65
cmpResponse . getVendorConsents = consentResponse ;
65
66
afterEach ( ) ;
66
67
}
@@ -82,7 +83,7 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
82
83
// if the CMP is not found, the iframe function will call the cmpError exit callback to abort the rest of the CMP workflow
83
84
try {
84
85
cmpFunction = window . __cmp || utils . getWindowTop ( ) . __cmp ;
85
- } catch ( e ) { }
86
+ } catch ( e ) { }
86
87
87
88
if ( utils . isFn ( cmpFunction ) ) {
88
89
cmpFunction ( 'getConsentData' , null , callbackHandler . consentDataCallback ) ;
@@ -97,7 +98,7 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
97
98
while ( ! cmpFrame ) {
98
99
try {
99
100
if ( f . frames [ '__cmpLocator' ] ) cmpFrame = f ;
100
- } catch ( e ) { }
101
+ } catch ( e ) { }
101
102
if ( f === window . top ) break ;
102
103
f = f . parent ;
103
104
}
@@ -139,13 +140,15 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) {
139
140
function callCmpWhileInIframe ( commandName , cmpFrame , moduleCallback ) {
140
141
/* Setup up a __cmp function to do the postMessage and stash the callback.
141
142
This function behaves (from the caller's perspective identicially to the in-frame __cmp call */
142
- window . __cmp = function ( cmd , arg , callback ) {
143
+ window . __cmp = function ( cmd , arg , callback ) {
143
144
let callId = Math . random ( ) + '' ;
144
- let msg = { __cmpCall : {
145
- command : cmd ,
146
- parameter : arg ,
147
- callId : callId
148
- } } ;
145
+ let msg = {
146
+ __cmpCall : {
147
+ command : cmd ,
148
+ parameter : arg ,
149
+ callId : callId
150
+ }
151
+ } ;
149
152
cmpCallbacks [ callId ] = callback ;
150
153
cmpFrame . postMessage ( msg , '*' ) ;
151
154
}
@@ -371,6 +374,9 @@ export function setConfig(config) {
371
374
utils . logError ( `consentManagement config with cmpApi: 'static' did not specify consentData. No consents will be available to adapters.` ) ;
372
375
}
373
376
}
374
- $$PREBID_GLOBAL$$ . requestBids . addHook ( requestBidsHook , 50 ) ;
377
+ if ( ! addedConsentHook ) {
378
+ $$PREBID_GLOBAL$$ . requestBids . addHook ( requestBidsHook , 50 ) ;
379
+ }
380
+ addedConsentHook = true ;
375
381
}
376
382
config . getConfig ( 'consentManagement' , config => setConfig ( config . consentManagement ) ) ;
0 commit comments