-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprobtn_double_loader_with_params_concat_pixel.js
118 lines (111 loc) · 4.71 KB
/
probtn_double_loader_with_params_concat_pixel.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
(function() {
function loadJS(current, src, callback) {
var s = current.document.createElement("script");
s.src = src;
s.async = true;
s.onreadystatechange = s.onload = function () {
var state = s.readyState;
if (!callback.done && (!state || /loaded|complete/.test(state))) {
callback.done = true;
callback();
}
};
current.document.getElementsByTagName("head")[0].appendChild(s);
}
var addLink = function(link) {
var trackingImage = window.self.document.createElement("img");
trackingImage.id = "probtn_dsp_includepb_tracking_image";
trackingImage.alt = "probtn_dsp_includepb_tracking_image";
trackingImage.src = link;
trackingImage.style.cssText = "position: absolute; top:-11111px; left: -11111px; width: 1px; height: 1px;";
document.body.appendChild(trackingImage);
};
var r = {
NO_IFRAME: 0,
IFRAME: 1,
UNKNOWN: 2,
XD_IFRAME: 3
};
function checkIframe() {
try {
if (window.top == window) return "NO_IFRAME";
for (var a = window, f = 0; a.parent != a && 1E3 > f;) {
f++;
if (a.parent.document.domain != a.document.domain) return "XD_IFRAME";
a = a.parent
}
return "IFRAME"
} catch (n) {}
return "XD_IFRAME";
}
var addSuperPixelLink = function(param) {
console.log(param);
var suf = "_ECLICK";
var out_param = param + suf;
addLink("https://pixel.probtn.com/1/from-ref?pbdebug=getintent&DeviceUID=&localDomain="+document.domain.replace("www.", "")+"&daction=" + out_param);
out_param = document.domain.replace("www.", "") + "_" + param + suf;
return true;
}
addSuperPixelLink(checkIframe() + "_" + "doublebanner" + "_" + "otm");
var callDSPlink = function() {
var dsp_settings = document.getElementById("probtn_dsp_params");
addLink("https://pixel.probtn.com/1/from-ref?pbdebug=getintent&DeviceUID=&localDomain="+document.domain.replace("www.", "")+"&daction=" + "callDSPlink");
if ((dsp_settings!==null) && (dsp_settings!==undefined)) {
var domain = "unknown_domain";
try {
domain = window.top.document.domain.replace("www.", "");
} catch(ex) {
console.log(ex);
}
if (document && document.domain) {
domain = document.domain.replace("www.", "");
}
try {
//https://dsp-parser.viewst.com/getdsp/:campaign_id/:domain/:frame/:publishers
var default_params = { "publishers": "unknown_publisher", "frame": checkIframe(), "domain": domain, "campaign_id": "unknown_campaign_id"};
var data = dsp_settings.innerHTML;
data = JSON.parse(data);
var dsp_params = Object.assign(default_params, data);
//addLink("https://dsp-parser.viewst.com/getdsppixel?pbdebug=getintent&DeviceUID=&localDomain="+document.domain.replace("www.", "")+"&daction=" + "campaign_id_" + dsp_params.campaign_id);
addLink("https://dsp-parser.viewst.com/getdspimg/?campaign_id="+ dsp_params.campaign_id + "_getdspimg&domain=" + dsp_params.domain + "&frame=" + dsp_params.frame + "&publishers=" + dsp_params.publishers);
//addLink("https://dsp-parser.viewst.com/getdsp/"+ dsp_params.campaign_id + "_getdsp/" + dsp_params.domain + "/" + dsp_params.frame + "/" + dsp_params.publishers);
//addLink("https://pixel.probtn.com/1/from-ref?pbdebug=getintent&DeviceUID=&localDomain="+document.domain.replace("www.", "")+"&daction=" + "campaign_id_" + dsp_params.campaign_id);
} catch(ex) {
console.log(ex);
//addLink("https://pixel.probtn.com/1/from-ref?pbdebug=getintent&DeviceUID=&localDomain="+document.domain.replace("www.", "")+"&daction=" + "error_" + ex.toString());
}
}
}
callDSPlink();
if (window.top !== window.self) {
try {
var probtn_content1 = window.top.document.createElement("div");
probtn_content1.id = "probtn_content1";
probtn_content1.innerHTML = document.getElementById("probtn_content1").innerHTML;
probtn_content1.style.cssText = "display: none;";
window.top.document.body.appendChild(probtn_content1);
loadJS(window.top, "https://cdn.viewst.com/probtn_concat.js", function() {
runBanner("IFRAME", "probtn_additional_params_banner_iframe");
});
} catch(ex) {
console.log("cant go to top");
console.log(ex);
}
} else {
loadJS(window.self, "https://cdn.viewst.com/probtn_concat.js", function() {
});
}
var runBanner = function(param, name) {
if ((checkIframe() === param)) {
var settings_banner = document.getElementById(name);
if ((settings_banner!==null) && (settings_banner!==undefined)) {
document.getElementById("probtn_additional_params").innerHTML = settings_banner.innerHTML;
loadJS(window.self, "https://cdn.viewst.com/probtn_concat.js", function() {
});
} else {
console.log("no " + name + " for " + param);
}
}
}
runBanner("XD_IFRAME", "probtn_additional_params_banner_safeframe");
})();