diff options
| author | sD <stoned@derpymail.org> | 2019-12-28 17:43:21 +0100 |
|---|---|---|
| committer | sD <stoned@derpymail.org> | 2019-12-28 17:43:21 +0100 |
| commit | 36be41939be460802712906d0b77620469ec4d19 (patch) | |
| tree | 0922b7b4d3a89a64ae4a50461f6b34626eb00c60 /webAO/master.js | |
| parent | bd507aba979f83d14947dc8d1ec6c8d09f9edcac (diff) | |
| parent | c94d7ccf9c3dbfe93589939aad7e163ca0e888fc (diff) | |
Merge branch 'master' into css_buttons
Diffstat (limited to 'webAO/master.js')
| -rw-r--r-- | webAO/master.js | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/webAO/master.js b/webAO/master.js index d12a7ec..863c311 100644 --- a/webAO/master.js +++ b/webAO/master.js @@ -9,7 +9,14 @@ const fp = new Fingerprint({ }); /** An emulated, semi-unique HDID that is generally safe for HDID bans. */ -const hdid = fp.get(); +const cookieid = getCookie("fingerprint"); +let hdid; +if (cookieid) { + hdid = cookieid; +} else { + hdid = fp.get(); + setCookie("fingerprint",hdid); +} console.log(`Your emulated HDID is ${hdid}`); let oldLoading = false; @@ -28,6 +35,38 @@ const server_description = []; server_description[-1] = "This is your computer on port 50001"; const online_counter = []; +/** + * read a cookie from storage + * got this from w3schools + * https://www.w3schools.com/js/js_cookies.asp + * @param {String} cname The name of the cookie to return + */ +function getCookie(cname) { + var name = cname + "="; + var decodedCookie = decodeURIComponent(document.cookie); + var ca = decodedCookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) === ' ') { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); + } + } + return ""; +} + +/** + * set a cookie + * the version from w3schools expects these to expire + * @param {String} cname The name of the cookie to return + * @param {String} value The value of that cookie option + */ +function setCookie(cname,value) { + document.cookie = cname + "=" + value; +} + export function setServ(ID) { console.log(server_description[ID]); if (server_description[ID] !== undefined) { |
