-
Notifications
You must be signed in to change notification settings - Fork 29
/
prebid.js
76 lines (69 loc) · 1.74 KB
/
prebid.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* eslint-disable func-names */
import {
hit,
noopFunc,
noopStr,
noopArray,
} from '../helpers/index';
/**
* @redirect prebid
*
* @description
* Mocks the prebid.js header bidding suit.
* https://docs.prebid.org/
*
* ### Examples
*
* ```adblock
* ||example.org/bd/hb/prebid.js$script,redirect=prebid
* ```
*
* @added v1.6.2.
*/
export function Prebid(source) {
const pushFunction = function (arg) {
if (typeof arg === 'function') {
try {
arg.call();
} catch (ex) {
/* empty */
}
}
};
const pbjsWrapper = {
addAdUnits() { },
adServers: {
dfp: {
// https://docs.prebid.org/dev-docs/publisher-api-reference/adServers.dfp.buildVideoUrl.html
// returns ad URL
buildVideoUrl: noopStr,
},
},
adUnits: [],
aliasBidder() { },
cmd: [],
enableAnalytics() { },
getHighestCpmBids: noopArray,
libLoaded: true,
que: [],
requestBids(arg) {
if (arg instanceof Object && arg.bidsBackHandler) {
try {
arg.bidsBackHandler.call(); // https://docs.prebid.org/dev-docs/publisher-api-reference/requestBids.html
} catch (ex) {
/* empty */
}
}
},
removeAdUnit() { },
setBidderConfig() { },
setConfig() { },
setTargetingForGPTAsync() { },
};
pbjsWrapper.cmd.push = pushFunction;
pbjsWrapper.que.push = pushFunction;
window.pbjs = pbjsWrapper;
hit(source);
}
Prebid.names = ['prebid'];
Prebid.injections = [hit, noopFunc, noopStr, noopArray];