Last active
December 12, 2016 09:04
-
-
Save englishextra/12dec2c7a796ab9ec5e9ed84b134c055 to your computer and use it in GitHub Desktop.
track visitors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* externalcounters.js | |
* track visitors | |
* gist.github.com/englishextra/12dec2c7a796ab9ec5e9ed84b134c055 | |
*/ | |
if (!/localhost/.test(self.location.host)) { | |
(function (b, a, c, d) { | |
if (c && d) { | |
var e = encodeURIComponent(a.referrer || ""); | |
b = encodeURIComponent(b.location.href || ""); | |
a = encodeURIComponent(("undefined" !== typeof initialDocumentTitle ? initialDocumentTitle : (a.title || "")).replace("\x27", "'").replace("\x28", "(").replace("\x29", ")")); | |
c.setAttribute("style", "position:absolute;left:-9999px;width:1px;height:1px;border:0;background:transparent url(" + d + "?dmn=" + b + "&rfrr=" + e + "&ttl=" + a + "&encoding=utf-8) top left no-repeat;"); | |
} | |
})(window, document, document.getElementById("externalcounters") || "", /localhost/.test(self.location.host) ? "http://localhost/externalcounters/" : "//shimansky.biz/externalcounters/"); | |
} | |
;(function (d) { | |
var g = /localhost/.test(self.location.host) ? "http://localhost/externalcounters/" : "//shimansky.biz/externalcounters/", | |
c = d.getElementsByTagName("a") || "", | |
a = self.location.protocol + "//" + self.location.host + "/" || "", | |
h = self.location.host + "/" || "", | |
k = encodeURIComponent(d.location.href || ""), | |
l = encodeURIComponent((d.title || "").replace("\x27", "'").replace("\x28", "(").replace("\x29", ")")); | |
if (c && a && h) { | |
var s = function () { | |
var a = this.getAttribute("href"), | |
c = document.body.firstChild, | |
f = d.createElement("div"); | |
f.setAttribute("style", "position:absolute;left:-9999px;width:1px;height:1px;border:0;background:transparent url(" + g + "?dmn=" + encodeURIComponent(a) + "&rfrr=" + k + "&ttl=" + l + "&encoding=utf-8) top left no-repeat;"); | |
c.parentNode.insertBefore(f, c); | |
}; | |
for (a = 0; a < c.length; a += 1) { | |
if (b = c[a], (e = b.getAttribute("href") || "") && (e.match(/^\/scripts\//) || /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)|(localhost)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/.test(e)) && !b.getAttribute("rel")) { | |
c[a].onclick = s; | |
} | |
} | |
} | |
})(document); | |
(function (k) { | |
k.addEventListener("blur", function () { | |
(function (d, w) { | |
var a = /localhost/.test(self.location.host) ? "http://localhost/externalcounters/" : "//shimansky.biz/externalcounters/", | |
b = encodeURIComponent(d.referrer || ""), | |
c = encodeURIComponent(w.location.href || ""), | |
e = encodeURIComponent((d.title || "").replace("\x27", "'").replace("\x28", "(").replace("\x29", ")") + " - \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043d\u0435 \u0430\u043a\u0442\u0438\u0432\u0435\u043d"), | |
f = d.createElement("div"), | |
g = document.body.firstChild; | |
f.setAttribute("style", "position:absolute;left:-9999px;width:1px;height:1px;border:0;background:transparent url(" + a + "?dmn=" + c + "\x26rfrr=" + b + "\x26ttl=" + e + "\x26encoding=utf-8) top left no-repeat;"); | |
g.parentNode.insertBefore(f, g); | |
} | |
(document, window)); | |
}, !1); | |
} | |
(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment