forked from pinterest/widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pinit.js
33 lines (24 loc) · 909 Bytes
/
pinit.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
/* jshint indent: false, maxlen: false */
(function (w, d, a) {
var hazPinIt, firstScript, newScript, scriptUrl;
// generate an unique-ish global variable: hazPinIt_ plus today's Unix day
hazPinIt = 'PIN_' + ~~(new Date().getTime() / 86400000);
if (!w[hazPinIt]) {
// keep track of the number of times pinit.js is included for debugging purposes
w[hazPinIt] = 1;
// avoid KB927917 error in IE8
w.setTimeout(function () {
// load payload
firstScript = d.getElementsByTagName('SCRIPT')[0];
newScript = d.createElement('SCRIPT');
newScript.type = 'text/javascript';
newScript.async = true;
newScript.src = a.mainUrl + '?' + Math.random();
firstScript.parentNode.insertBefore(newScript, firstScript);
}, 10);
} else {
w[hazPinIt] += 1;
}
}(window, document, {
'mainUrl': 'https://assets.pinterest.com/js/pinit_main.js'
}));