-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathutils.js
36 lines (30 loc) · 1.08 KB
/
utils.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
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.loadGPTScript = loadGPTScript;
var GPT_SRC = {
standard: 'securepubads.g.doubleclick.net',
limitedAds: 'pagead2.googlesyndication.com'
};
function doloadGPTScript(resolve, reject, limitedAds) {
window.googletag = window.googletag || {};
window.googletag.cmd = window.googletag.cmd || [];
var scriptTag = document.createElement('script');
scriptTag.src = "".concat(document.location.protocol, "//").concat(limitedAds ? GPT_SRC.limitedAds : GPT_SRC.standard, "/tag/js/gpt.js");
scriptTag.async = true;
scriptTag.type = 'text/javascript';
scriptTag.onerror = function scriptTagOnError(errs) {
reject(errs);
};
scriptTag.onload = function scriptTagOnLoad() {
resolve(window.googletag);
};
document.getElementsByTagName('head')[0].appendChild(scriptTag);
}
function loadGPTScript() {
var limitedAds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
return new Promise(function (resolve, reject) {
doloadGPTScript(resolve, reject, limitedAds);
});
}