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