防覆盖
var isFromTuia = (function () { var tuiaDomains = ['tuisnake', 'localhost'] function GetUrlDomain(url) { var arrUrl = url.split("//"); var start = arrUrl[1].indexOf("/"); var relUrl = arrUrl[1].substring(0, start); //stop省略,截取从start开始到结尾的所有字符 return relUrl; } var es = document.getElementsByTagName('script'); var iScript = es[es.length - 1] if (iScript && iScript.src) { var iDomain = GetUrlDomain(iScript.src); for (var i = 0; i < tuiaDomains.length; i++) { if (iDomain.indexOf(tuiaDomains[i]) != -1) { return true; } } } return false; })(); function defineTaWin(key, value, isFreeze) { if (Object.defineProperty && isFreeze) { Object.defineProperty(window, key, { writable: false, value: value }); } else { window[key] = value; } } defineTaWin('countLog', countLog, isFromTuia);