Alukard_X
Grand Guru
- Joined
- Oct 3, 2020
- Messages
- 843
JavaScript:
(function(d) {
let userCdnTracker = {
generateUUID: function() {
var S4 = function() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
},
isFunction: function isFunction(obj) {
return typeof obj === "function" && typeof obj.nodeType !== "number" && typeof obj.item !== "function";
},
isPlainObject: function(obj) {
var proto, Ctor;
if (!obj || toString.call(obj) !== "[object Object]") {
return false;
}
var fnToString = hasOwn.toString;
var ObjectFunctionString = fnToString.call(Object);
function getProto(obj) {
return Object.getPrototypeOf;
}
proto = getProto(obj);
if (!proto) {
return true;
}
let hasOwn;
Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
},
isEmptyObject: function(obj) {
var name;
for (name in obj) {
return false;
}
return true;
},
getCurrentDomain: function() {
const {hostname} = window.location;
const parts = hostname.split('.');
if (parts.length === 2) {
return '.' + hostname;
}
return '.' + parts.slice(-2).join('.');
},
setCookie: function(name, value, hours) {
const domain = this.getCurrentDomain();
var expires = "";
if (hours) {
var date = new Date();
date.setTime(date.getTime() + (hours * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/" + "; domain=" + domain;
},
Last edited: