diff options
| author | stonedDiscord <stoned@derpymail.org> | 2018-05-14 19:23:54 +0200 |
|---|---|---|
| committer | stonedDiscord <stoned@derpymail.org> | 2018-05-14 19:23:54 +0200 |
| commit | 2630392deef2fbaea192ef2572714b307d676356 (patch) | |
| tree | 8949fb2bcdd0568f5aeb171d55588ac2616e1735 | |
| parent | 26c12c9461be9c52057983f1240ac3bad57b68c1 (diff) | |
hashing useragent
it wouldn't load on mobiles because of this
| -rw-r--r-- | client.js | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -69,6 +69,21 @@ if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phon var carea = 0; var linifile; var pinifile; +var hdid; + +hashCode = function(str) { + var hash = 0, i, chr, len; + if (str.length === 0) return hash; + for (i = 0, len = str.length; i < len; i++) { + chr = str.charCodeAt(i); + hash = ((hash << 5) - hash) + chr; + hash |= 0; // Convert to 32bit integer + } + return hash; + }; + +hdid = hashCode(navigator.userAgent); + serv.onopen = function(evt) { onOpen(evt) }; @@ -335,7 +350,7 @@ function updateText() { function onOpen(e) { if (mode == "join") { - serv.send("HI#" + navigator.userAgent + "#%"); + serv.send("HI#" + hdid + "#%"); serv.send("ID#webAO#2.4.5#%"); } else { document.getElementById("client_loading").style.display = "none"; @@ -350,13 +365,13 @@ function onClose(e) { function ReconnectButton() { serv = new WebSocket("ws://" + serverIP); if (serv) { - serv.send("HI#" + navigator.userAgent + "#%"); + serv.send("HI#" + hdid + "#%"); document.getElementById("client_error").style.display = "none"; } } function RetryButton() { -serv.send("HI#" + navigator.userAgent + "#%"); +serv.send("HI#" + hdid + "#%"); } function onError(e) { |
