1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | function injectSnippet(scriptURL, backupScriptURL) {
|
9 | (function (w, d, s, c, f, n, t, g, a, b, l) {
|
10 |
|
11 |
|
12 | w.PactSafeObject = n;
|
13 | w[n] = w[n] || function () {
|
14 | (w[n].q = w[n].q || []).push(arguments);
|
15 | }, w[n].on = function () {
|
16 |
|
17 | (w[n].e = w[n].e || []).push(arguments);
|
18 | }, w[n].once = function () {
|
19 | (w[n].eo = w[n].eo || []).push(arguments);
|
20 | }, w[n].off = function () {
|
21 | (w[n].o = w[n].o || []).push(arguments);
|
22 | }, w[n].t = 1 * new Date(), w[n].l = 0;
|
23 |
|
24 |
|
25 | a = d.createElement(s);
|
26 | b = d.getElementsByTagName(s)[0];
|
27 | a.async = 1;
|
28 | a.src = c;
|
29 |
|
30 |
|
31 | a.onload = a.onreadystatechange = function () {
|
32 | w[n].l = 1;
|
33 | };
|
34 | a.onerror = a.onabort = function () {
|
35 | w[n].l = 0;
|
36 | };
|
37 |
|
38 |
|
39 | if (b) {
|
40 | b.parentNode.insertBefore(a, b);
|
41 | } else {
|
42 | document.body.appendChild(a);
|
43 | }
|
44 |
|
45 |
|
46 | setTimeout(function () {
|
47 | if (!w[n].l && !w[n].loaded) {
|
48 | w[n].error = 1;
|
49 | a = d.createElement(s);
|
50 | a.async = 1;
|
51 | a.src = f;
|
52 | a.onload = a.onreadystatechange = function () {
|
53 | w[n].l = 1;
|
54 | };
|
55 | a.onerror = a.onabort = function () {
|
56 | w[n].l = 0;
|
57 | };
|
58 | b.parentNode.insertBefore(a, b);
|
59 |
|
60 |
|
61 | l = function l(u, e) {
|
62 | try {
|
63 | e = d.createElement("img");
|
64 | e.src = "https://d3r8bdci515tjv.cloudfront.net/error.gif?t=" + w[n].t + "&u=" + encodeURIComponent(u);
|
65 | d.getElementsByTagName("body")[0].appendChild(e);
|
66 | } catch (x) {}
|
67 | };
|
68 | l(c);
|
69 |
|
70 |
|
71 | setTimeout(function () {
|
72 | if (!w[n].l && !w[n].loaded) {
|
73 | w[n].error = 1;
|
74 | if (g && "function" == typeof g) {
|
75 | g.call(this);
|
76 | }
|
77 | l(f);
|
78 | }
|
79 | }, t);
|
80 | }
|
81 | }, t);
|
82 | })(window, document, "script", scriptURL, backupScriptURL, "_ps", 4000, function optionalErrorCallback() {
|
83 | console.log("Unable to load the PactSafe PS.JS Library.");
|
84 | });
|
85 | }
|
86 |
|
87 | function isSnippetLoaded(psScriptURL) {
|
88 | var scripts = document.getElementsByTagName('script');
|
89 | if (window._ps && window._ps.loaded && window._ps.realThang === 317) return true;
|
90 | for (var i = 0; i < scripts.length; i += 1) {
|
91 | if (scripts[i].src.indexOf(psScriptURL) !== -1) {
|
92 | return true;
|
93 | }
|
94 | }
|
95 | return false;
|
96 | }
|
97 |
|
98 | module.exports = {
|
99 | injectSnippet: injectSnippet,
|
100 | isSnippetLoaded: isSnippetLoaded
|
101 | }; |
\ | No newline at end of file |