(function() { var magoq_options = { goquser : '', user_key : '', temporary : '', duration : 0, clear_interval : 0, clear_interval2 : 0, property : '', goqrep : '', cursor : [], goqsystem: 'user' }; var magoq = (function(){ return { getCookie: function(name){ if (!name || !document.cookie) return ''; var cookies = document.cookie.split("; "); for (var i = 0; i < cookies.length; i++) { var str = cookies[i].split("="); if (str[0].trim() != name) continue; return unescape(str[1]); } return ''; }, checkCookie: function(){ magoq_options.clear_interval = setInterval(magoq.intervalEvent,1000); magoq_options.clear_interval2 = setInterval(magoq.onLoadEvent,5000); var matchuser = location.search.match(/goquser=(.*?)(&|$)/); if(matchuser != 'null' && matchuser != '') { try { magoq_options.goquser = decodeURIComponent(matchuser[1]); } catch (ex) { magoq_options.goquser = ''; } } var userkey = magoq.getCookie('_userkey'); var cName = "_userkey="; if (userkey != '' ) { var dTime = new Date(); dTime.setYear(dTime.getYear() - 1); document.cookie = cName + ';expires=' + dTime.toGMTString() + ';path=/'; magoq_options.user_key = userkey; } else { magoq_options.user_key = '9onacnj2vplogn1aghp1l031i7'; } //console.log(magoq_options.user_key); var expire = new Date(); expire.setTime( expire.getTime() + (2145916800000 - expire.getTime())); document.cookie = cName + magoq_options.user_key + ';expires=' + expire.toString() + ';path=/'; if (typeof(form_value) != "undefined") { form_value.user_key = magoq_options.user_key; } magoq.TemporaryMemory(); var match = location.search.match(/goqtag=(.*?)(&|$)/); if (match == null || match == '') { match = location.hash.match(/goqtag=(.*?)(&|$)/); } if(match != null && match != '') { try { magoq_options.property = decodeURIComponent(match[1]); } catch (ex) { magoq_options.property = ''; } } var matchgoqrep = location.search.match(/goqrep=(.*?)(&|$)/); if (matchgoqrep == null || matchgoqrep == '') { matchgoqrep = location.hash.match(/goqrep=(.*?)(&|$)/); } if(matchgoqrep != null && matchgoqrep != '') { try { magoq_options.goqrep = decodeURIComponent(matchgoqrep[1]); } catch (ex) { magoq_options.goqrep = ''; } } console.log('checkCookie END'); }, TemporaryMemory: function(){ var expire = new Date(); var temp = this.getCookie('_temp'); if (temp) { magoq_options.temporary = temp; } else { magoq_options.temporary = expire.getTime(); } expire.setTime( expire.getTime() + 1800000); document.cookie = '_temp=' + magoq_options.temporary + ';expires=' + expire.toString() + ';path=/'; }, intervalEvent: function(){ magoq_options.duration++; if (magoq_options.duration > 1800) { clearInterval(magoq_options.clear_interval); clearInterval(magoq_options.clear_interval2); } }, onLoadEvent: function(){ console.log('onLoad'); inputs = { ma : 'MHQteWFtYTEwMUBhZGJyYXZlLmpw' ,access_ip : 'MTE5LjIzMC4yNDcuNDY=' ,access_page : document.title ,access_url : window.location.href ,access_referer : document.referrer ,access_user_agent : 'Mozilla/5.0(Windows;U;WindowsNT6.1;en-US)AppleWebKit/533.20.25(KHTML,likeGecko)Version/5.0.4Safari/533.20.27' ,session_id : '9onacnj2vplogn1aghp1l031i7' ,user_key: magoq_options.user_key ,goquser : magoq_options.goquser ,duration : magoq_options.duration ,property : magoq_options.property ,temporary : magoq_options.temporary ,cursor : magoq_options.cursor }; var xhr = new XMLHttpRequest(); var url = "https://log.goq.jp/accessIP/"; xhr.open("POST", url, true); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { // console.log(magoq_options.goqrep); } else { clearInterval(magoq_options.clear_interval); clearInterval(magoq_options.clear_interval2); switch (xhr.responseText.code) { case '9': console.log(xhr.responseText.msg); break; default: console.log(xhr.responseText); break; } } } }; var data = JSON.stringify(inputs); xhr.send(data); if (magoq_options.goqrep != ''){ location.href = magoq_options.goqrep; } } }; })(); if (window.addEventListener){ window.addEventListener('beforeunload', magoq.onLoadEvent, true); } magoq.checkCookie(); magoq.onLoadEvent(); // var el = document.body; // el.onmousemove = function(e){ // magoq_options.cursor.push({ x: e.offsetX, y: e.offsetY}); // }; }());