Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict";
- var PageJson, websocket, appframeLoaded, OfflinePushToken, radio, Page = "",
- LastActionHero = "",
- SavedId = "",
- https = "https:",
- ConsoleOff = false,
- w_Vol = [35, 35, 35],
- w_sound = 1,
- ReleaseMode = 0,
- xConfig = {
- name: "box",
- origin: "file://",
- debugLogIgnore: [],
- debugNoLogs: false
- };
- xConfig.origin = "https://xat.com", xConfig.debugNoLogs = false, console.log = function(i, a, s) {
- return function() {
- if (1 != xConfig.debugNoLogs) {
- var e = new Array;
- for (var o in arguments) 0 != o || "." != arguments[0].toString()[0] ? (0 == o && e.push("." + a), e.push(arguments[o])) : e.push("." + a + arguments[0].toString());
- var t = e[0].toString();
- for (var n in s)
- if (t.startsWith(s[n])) return;
- return i.apply(this, e)
- }
- }
- }(console.log.bind(console), xConfig.name, xConfig.debugLogIgnore);
- var trace = console.log,
- sp_ids = ["home", "profile", "friends", "chats", "groups", "settings", "store", "buy", "help", "visitors", "classic"];
- for (var i in sp_ids) {
- var j = document.getElementById("sp_" + sp_ids[i]);
- j && (j.sp = sp_ids[i], j.addEventListener("click", function(e) {
- actSetPage(e.currentTarget.sp)
- }))
- }
- function activityMain() {
- var e = activityToC("xatInit", "", "");
- console.log("Done xatInit"), setPage(ClassicGroup ? "classic" : 0 == e ? "profile" : "chats");
- activityToC("setContacts", "", ""), activityToC("xatMain", "", ""), console.log("Done xatMain"), activityToC("leaveBackground", "", ClassicGroup), ConsoleOff = false, activityToC("SetPhoneFontSize", "", "1.0"), activityToC("setLang", "", window.navigator.userLanguage || window.navigator.language), ClassicGroup && activityToC("xatCommand", "", JSON.stringify({
- Command: "StartGroup",
- Group: ClassicGroup
- })), setInterval(function() {
- TimerMethod()
- }, 100), activityToC("xatCommand", "", JSON.stringify({
- Command: "EnableTick"
- }))
- }
- function setPage(e) {
- var o;
- if (e && ("pop" == e && "classic" == Page && (o = !0, e = Page), e = activityToC("SetPage", "", e), o || e != Page)) switch ("profile" == (Page = e) && (e = "actions"), activityToC("viewWillDisappear", "", ""), e) {
- case "captcha":
- var t = JSON.stringify(PageJson);
- (n = document.getElementById("appframe")).src = https + "//xat.com/web_gear/chat/AreYouaHuman.php?m=3&j=" + t;
- break;
- case "classic":
- default:
- var n;
- (n = document.getElementById("appframe")).onload = function(e) {
- appframeLoaded = !0, activityToC("webViewDidFinishLoad", "", "")
- }, n.src = "www/" + e + ".html"
- }
- }
- function DoPageClick(e) {
- if ("string" == typeof e && (e = decodeURIComponent((e + "").replace(/\+/g, "%20")), e = JSON.parse(e)), "xtrace" != (PageJson = e).Type)
- if (PageJson.Page) {
- var o = PageJson.LastActionHero;
- o || (o = "");
- var t = PageJson.SavedId;
- t || (t = ""), LastActionHero == o && SavedId == t || activityToC("LastActionHero", LastActionHero = o, SavedId = t);
- var n = PageJson.Next;
- switch (PageJson.Command) {
- case "":
- case "NOP":
- case "HitWeb":
- break;
- case "Action":
- switch (PageJson.name) {
- case "BuyXats":
- case "MakePurchase":
- return
- }
- default:
- activityToC("xatCommand", "", JSON.stringify(PageJson))
- }
- ClassicGroup && "captcha" != n && "pop" != n || setPage(n)
- } else console.log("!!** No Page **!! ")
- }
- var encodings = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- function base64ArrayBuffer(e) {
- for (var o, t, n, i, a = "", s = new Uint8Array(e), r = s.byteLength, c = r % 3, l = r - c, d = 0; d < l; d += 3) o = (258048 & (i = s[d] << 16 | s[d + 1] << 8 | s[d + 2])) >> 12, t = (4032 & i) >> 6, n = 63 & i, a += encodings[(16515072 & i) >> 18] + encodings[o] + encodings[t] + encodings[n];
- return 1 == c ? (o = (3 & (i = s[l])) << 4, a += encodings[(252 & i) >> 2] + encodings[o] + "==") : 2 == c && (o = (1008 & (i = s[l] << 8 | s[l + 1])) >> 4, t = (15 & i) << 2, a += encodings[(64512 & i) >> 10] + encodings[o] + encodings[t] + "="), a
- }
- function toUTF8ArrayBuf(e) {
- for (var o = [], t = 0; t < e.length; t++) {
- var n = e.charCodeAt(t);
- n < 128 ? o.push(n) : n < 2048 ? o.push(192 | n >> 6, 128 | 63 & n) : n < 55296 || 57344 <= n ? o.push(224 | n >> 12, 128 | n >> 6 & 63, 128 | 63 & n) : (t++, n = 65536 + ((1023 & n) << 10 | 1023 & e.charCodeAt(t)), o.push(240 | n >> 18, 128 | n >> 12 & 63, 128 | n >> 6 & 63, 128 | 63 & n))
- }
- var i = o.length,
- a = new ArrayBuffer(i),
- s = new Uint8Array(a);
- for (t = 0; t < i; t++) s[t] = o[t];
- return a
- }
- function xatSend(e, o) {
- if (0 <= o.search("zz45") && (o = '<bs u="225248065" s="fred" />'), console.log("xatSend=" + e + "," + o), websocket) {
- var t = toUTF8ArrayBuf(o);
- websocket.send(t)
- }
- }
- function xatClose() {
- isOpen = !1, console.log("xatClose"), websocket && (xatSend(0, "<C />"), websocket.close(), websocket = null)
- }
- function DoNotify(e, o) {
- switch (e) {
- case "FifoNotification":
- if (!appframeLoaded) return;
- var t, n = JSON.parse(o);
- trace(n);
- for (var i = document.getElementById("appframe").contentWindow, a = 0; a < n.length; a++)
- if ("{" == n[a].charAt(0)) switch ((t = JSON.parse(n[a])).Command) {
- case "SendSound":
- w_Vol = [xInt(t[1]), xInt(t[2]), xInt(t[3])], w_sound = xInt(t.w_sound), i.SetSpkIcon && i.SetSpkIcon(w_sound, t.HasRadio);
- break;
- case "PlayRadio":
- if (radio && (radio.unload(), radio = null), !t.Radio || 0 == w_Vol[1] || 0 == (2 & w_sound)) break;
- (radio = new Howl({
- src: [t.Radio],
- html5: !0,
- volume: w_Vol[1] / 100
- })).play();
- break;
- case "PlaySound":
- break;
- case "ToSideapp":
- parent.sideframe && parent.sideframe.postMessage(JSON.stringify(t), xConfig.origin);
- break;
- case "setCount":
- setCount && setCount(t.setCount);
- break;
- case "LocalNotify":
- if (!LocalNotify) break;
- if (!document[hidden]) break;
- notify.show(t.n, t.t)
- } else try {
- i.eval(n[a].toString())
- } catch (e) {
- var s = n[a].toString().match(/^([a-z]*)\./);
- s && s[1] && !i[s[1]] || console.log("FIFO ERR " + e + " " + n[a].toString())
- }
- return;
- case "SetGroupsPage":
- return void setPage("groups");
- case "SetChatsPage":
- return void setPage("chats");
- case "SetMePage":
- return void setPage("profile");
- case "SetBackPage":
- return void setPage("pop");
- case "SetVisitors":
- return void(i = document.getElementById("appframe").contentWindow).openList(0, "visitors", 0);
- default:
- console.log("!!** DoNotify TODO **!!/", notify)
- }
- }
- function DoAlert(e) {
- alert(e)
- }
- function DoLangs(e, o) {}
- var ConnectIp, ConnectPort, ClassicGroup, LocalNotify, LOADURL = 1,
- SEND = 2,
- CLOSE = 3,
- CONNECT = 4,
- NOTIFY = 5,
- ALERT = 6,
- HTTP = 7,
- LANGS = 8,
- FINISHTRANSACTION = 9,
- LOG = 10,
- SAVESOL = 11,
- LOADSOL = 12,
- isOpen = !1;
- function FromC(e, o, t) {
- switch (xInt(e)) {
- case SAVESOL:
- if ("undefined" == typeof Storage) break;
- localStorage.setItem(o, t);
- break;
- case LOADSOL:
- if ("undefined" == typeof Storage) break;
- localStorage.getItem(o), localStorage.setItem(o, t);
- break;
- case LOG:
- console.log(".FromC", t);
- break;
- case LOADURL:
- console.log("LOADURL," + o + "," + t);
- var n = new XMLHttpRequest,
- i = o;
- n.onreadystatechange = function() {
- 4 === n.readyState && (200 === n.status ? activityToC("xatURL", n.responseURL, n.responseText) : console.log("LOADURL Err:" + n.status))
- }, t ? (n.open("POST", i, !0), n.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), n.send("json=" + t)) : (n.open("GET", i, !0), n.send());
- break;
- case SEND:
- console.log("SEND," + o + "," + t), xatSend(o, t);
- break;
- case CLOSE:
- console.log("CLOSE," + o + "," + t), xatClose();
- break;
- case CONNECT:
- o = "wss://wss.xatbox.com", t = 443, console.log("CONNECT," + o + "," + t), xatClose(), ConnectIp = o, ConnectPort = xInt(t) + "/v2", (websocket = new WebSocket(ConnectIp + ":" + ConnectPort)).binaryType = "arraybuffer", websocket.onopen = function(e) {
- isOpen = !0, activityToC("xatMessageReceived", "#CONNECT_OK", "")
- }, websocket.onclose = function(e) {
- 1e3 != e.code && console.log("WebSocket CLOSE ERROR:" + e.code), activityToC("xatMessageReceived", "#CONNECT_CLOSE", ""), isOpen = !1
- }, websocket.onmessage = function(e) {
- activityToC("xatMessageReceived", "#MESSAGE", base64ArrayBuffer(e.data))
- }, websocket.onerror = function(e) {
- console.log("WebSocket ERROR")
- };
- break;
- case NOTIFY:
- console.log(".FromCNotify", "NOTIFY," + o), DoNotify(o, t);
- break;
- case ALERT:
- DoAlert(o);
- break;
- case HTTP:
- https = "http:";
- break;
- case LANGS:
- DoLangs(o, t)
- }
- }
- function TimerMethod() {
- for (var e = activityToC("xatTick", "", ""); e;) {
- var o = JSON.parse(e);
- o && FromC(o.Type, o.Cmd, o.Data), e = activityToC("ReadToJavaFifo", "", "")
- }
- OfflinePushToken && (activityToC("setToken", "", OfflinePushToken), OfflinePushToken = "")
- }
- function xLog(e) {
- console.log(e)
- }
- function onBackPressed() {
- console.log("onBackPressed"), setPage("pop")
- }
- function xInt(e) {
- return e = parseInt(e), isNaN(e) ? 0 : e
- }
- function activityToC(e, o, t) {
- "xatTick" != e && "ReadToJavaFifo" != e && console.log(".activityToC", e + " " + o + " " + t);
- var n = 2 * (2 * e.length + 1),
- i = Module._malloc(n);
- Module.stringToUTF8(e, i, n);
- var a = 2 * (2 * o.length + 1),
- s = Module._malloc(a);
- Module.stringToUTF8(o, s, a);
- var r = 2 * (2 * t.length + 1),
- c = Module._malloc(r);
- Module.stringToUTF8(t, c, r);
- var l = Module.ccall("cToC", null, ["number", "number", "number"], [i, s, c]),
- d = Pointer_stringify(l);
- return Module._free(l), d
- }
- function setCount(e) {
- var o = document.getElementById("idactcount");
- 0 < e ? (9 < e && (e = "9+"), o.innerText = e, o.style.visibility = "visible") : o.style.visibility = "hidden"
- }
- function onMore(e) {
- document.getElementById("dropdown-content").style.display = "block"
- }
- function anyClick(e) {
- document.getElementById("dropdown-content").style.display = "none"
- }
- function SetClassicMode(e) {
- if (e) {
- var o = document.getElementById("actionbar");
- o.style.height = "0%", o.style.display = "none", document.getElementById("app").style.height = "100%"
- }
- }
- function actSetPage(e) {
- if ("buy" != e)
- if ("home" === e);
- else if ("classic" === e) {
- SetClassicMode(!0), document.getElementById("appframe").src = "www/classic.html", setPage(e)
- } else setPage(e);
- else window.open("https://xat.com/buy", "_blank")
- }
- document.addEventListener("click", anyClick, !0);
- var hidden, visibilityChange, Module = {
- preRun: [],
- postRun: [jsMain],
- print: function(e) {
- 1 < arguments.length && (e = Array.prototype.slice.call(arguments).join(" ")), e = String(e).replace(/\/n/g, "\n"), console.log("!print=" + e)
- },
- printErr: function(e) {
- 1 < arguments.length && (e = Array.prototype.slice.call(arguments).join(" ")), console.error("!printErr=" + e)
- },
- canvas: [],
- setStatus: function(e) {
- 1 < arguments.length && (e = Array.prototype.slice.call(arguments).join(" ")), console.log("!setStatus=" + e)
- },
- totalDependencies: 0,
- monitorRunDependencies: function(e) {
- this.totalDependencies = Math.max(this.totalDependencies, e), Module.setStatus(e ? "Preparing... (" + (this.totalDependencies - e) + "/" + this.totalDependencies + ")" : "All downloads complete.")
- }
- };
- function jsMain() {
- parent && ((ClassicGroup = getParameterByName("gn", parent.window.location.href)) || (ClassicGroup = getParameterByName("id", parent.window.location.href)) && (ClassicGroup = "xat" + ClassicGroup)), ClassicGroup || (ClassicGroup = getParameterByName("n")), ClassicGroup || (ClassicGroup = "Lobby"), ClassicGroup && (ClassicGroup = ClassicGroup.replace(/[^0-9a-zA-Z_]/g, "")), ClassicGroup ? SetClassicMode(!0) : document.getElementById("actionbar").style.display = "block", notify.compatible() && notify.authorize(), activityMain()
- }
- function getParameterByName(e, o) {
- o || (o = window.location.href), e = e.replace(/[\[\]]/g, "\\$&");
- var t = new RegExp("[?&]" + e + "(=([^&#]*)|&|#|$)").exec(o);
- return t ? t[2] ? decodeURIComponent(t[2].replace(/\+/g, " ")) : "" : null
- }
- function getAnchor(e) {
- return e.substring(e.indexOf("#") + 1)
- }
- function onMessage(e) {
- if (e.origin === xConfig.origin) {
- var o = JSON.parse(e.data);
- trace(o), activityToC("xatCommand", "", JSON.stringify({
- Command: "lcAppToChat",
- channel: o.channel,
- user: o.user,
- msg: o.msg
- }))
- } else trace("onMessage Bad Origin=", e.origin, e)
- }
- function handleVisibilityFocusChange() {}
- function loadJsModule(n, i) {
- return new Promise(function(e, o) {
- var t = document.createElement("script");
- t.src = n, t.async = !0, t.onload = function() {
- return e()
- }, t.onerror = function() {
- var e = "file not found: " + n;
- if (!i) throw e;
- o(e)
- }, document.head.appendChild(t)
- })
- }
- window.onerror = function() {
- Module.setStatus("Exception thrown, see JavaScript console"), Module.setStatus = function(e) {
- e && Module.printErr("[post-exception status] " + e)
- }
- }, window.addEventListener("message", onMessage, !1), void 0 !== document.hidden ? (hidden = "hidden", visibilityChange = "visibilitychange") : void 0 !== document.msHidden ? (hidden = "msHidden", visibilityChange = "msvisibilitychange") : void 0 !== document.webkitHidden && (hidden = "webkitHidden", visibilityChange = "webkitvisibilitychange"), void 0 === document.addEventListener || void 0 === document.hidden ? console.log("error: no support for Page Visibility API.") : document.addEventListener(visibilityChange, handleVisibilityFocusChange, !1), window.addEventListener("focus", handleVisibilityFocusChange), window.addEventListener("blur", handleVisibilityFocusChange), window.notify = {
- list: [],
- id: 0,
- compatible: function() {
- return "undefined" != typeof Notification
- },
- authorize: function() {
- notify.compatible() && Notification.requestPermission(function(e) {
- LocalNotify = "granted" == e
- })
- },
- show: function(e, o) {
- if (LocalNotify) {
- notify.id++;
- var t = notify.id;
- notify.list[t] = new Notification(e, {
- body: o,
- tag: t,
- icon: "https://xat.com/images/planet.svg",
- lang: "",
- dir: "auto"
- }), notify.logEvent("Notification #" + t + " queued for display"), notify.list[t].onclick = function() {
- notify.logEvent(t, "clicked")
- }, notify.list[t].onshow = function() {
- notify.logEvent(t, "showed")
- }, notify.list[t].onerror = function() {
- notify.logEvent(t, "errored")
- }, notify.list[t].onclose = function() {
- notify.logEvent(t, "closed")
- }, console.log("Created a new notification ..."), console.log(notify.list[t])
- }
- },
- logEvent: function(e, o) {}
- };
- var userbrowser, browsers = ["Chrome", "Edge", "Firefox", "Safari", "OPR", "MSIE", "Trident"],
- useragent = navigator.userAgent;
- for (i = 0; i < browsers.length; i++)
- if (-1 < useragent.indexOf(browsers[i])) {
- userbrowser = browsers[i];
- break
- }
- switch (userbrowser) {
- case "Chrome":
- case "Firefox":
- case "OPR":
- loadJsModule("www/firebase.js")
- }
- loadJsModule("www/howler.js"), window.WebAssembly ? loadJsModule("xatcorewasm.php", 1).then(function(e) {}, function(e) {
- loadJsModule("xatcore.php")
- }) : loadJsModule("xatcore.php");
Add Comment
Please, Sign In to add comment