function getCookie(name) { const cookies = document.cookie.split(';'); for (let cookie of cookies) { const [cookieName, cookieValue] = cookie.trim().split('='); if (cookieName === name) { return cookieValue; } } return null; } function setCookie(name, value) { const date = new Date(); date.setMonth(date.getMonth() + 1); // 当前时间 + 1个月 document.cookie = `${name}=${value}; expires=${date.toUTCString()}; path=/`; } const timestamp = Date.now(); // 获取当前时间戳 var chat_user='chat_'+timestamp.toString(); if(!getCookie('chat_user')){ setCookie('chat_user', chat_user); console.log("当前Cookie:", document.cookie); }else{ chat_user=getCookie('chat_user'); console.log("已设置当前Cookie:", document.cookie); } window.onload = function(){ var domain="https://chat.mijingtong.com"; var host=document.location.hostname; var url=domain+"/js/jquery.min.js"; var script = document.createElement('script'); script.setAttribute('type','text/javascript'); script.setAttribute('src',url); document.getElementsByTagName('head')[0].appendChild(script); var d = new Date(); var url2=domain+"/customer_service/kf.php?id=5&time="+d.getSeconds(); var script2 = document.createElement('script'); script2.setAttribute('type','text/javascript'); script2.setAttribute('src',url2); var xmlHttp=new XMLHttpRequest();     xmlHttp.open("GET",domain+"/customer_service/?host="+host+"&id=5&chat_user="+chat_user,true);     xmlHttp.send(null);     xmlHttp.onreadystatechange=function () {       if (xmlHttp.readyState ==4 && xmlHttp.status ==200){ //console.log(xmlHttp.responseText); var body=document.getElementsByTagName('body')[0]; var ndiv=document.createElement('div'); ndiv.innerHTML=xmlHttp.responseText; body.appendChild(ndiv); body.appendChild(script2);       }     } } function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i