aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstonedDiscord <stoned@derpymail.org>2018-05-14 19:23:54 +0200
committerstonedDiscord <stoned@derpymail.org>2018-05-14 19:23:54 +0200
commit2630392deef2fbaea192ef2572714b307d676356 (patch)
tree8949fb2bcdd0568f5aeb171d55588ac2616e1735
parent26c12c9461be9c52057983f1240ac3bad57b68c1 (diff)
hashing useragent
it wouldn't load on mobiles because of this
-rw-r--r--client.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/client.js b/client.js
index e67fa23..4fe2cad 100644
--- a/client.js
+++ b/client.js
@@ -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) {