diff --git a/src/constants.js b/src/constants.js index dad381a7..470807b3 100644 --- a/src/constants.js +++ b/src/constants.js @@ -1,10 +1,12 @@ var SVGPATH = '', DEBUG = localStorage.ffzDebugMode == "true" && document.body.classList.contains('ffz-dev'), + WS_SERVER = DEBUG ? "localhost:8001" : "catbag.frankerfacez.com", SERVER = DEBUG ? "//localhost:8000/" : "//cdn.frankerfacez.com/"; module.exports = { DEBUG: DEBUG, SERVER: SERVER, + WS_SERVER: WS_SERVER, API_SERVER: "//api.frankerfacez.com/", API_SERVER_2: "//direct-api.frankerfacez.com/", diff --git a/src/socket.js b/src/socket.js index 6263c280..2eae3781 100644 --- a/src/socket.js +++ b/src/socket.js @@ -1,4 +1,5 @@ -var FFZ = window.FrankerFaceZ; +var FFZ = window.FrankerFaceZ, + constants = require('./constants'); FFZ.prototype._ws_open = false; FFZ.prototype._ws_delay = 0; @@ -12,6 +13,8 @@ FFZ.ws_on_close = []; // Socket Creation // ---------------- +// Attempt to authenticate to the socket server as a real browser by loading the root page. +// e.g. cloudflare ddos check FFZ.prototype.ws_iframe = function() { this._ws_last_iframe = Date.now(); var ifr = document.createElement('iframe'), @@ -36,7 +39,7 @@ FFZ.prototype.ws_create = function() { this._ws_pending = this._ws_pending || []; try { - ws = this._ws_sock = new WebSocket("ws://catbag.frankerfacez.com/"); + ws = this._ws_sock = new WebSocket("ws://" + constants.WS_SERVER + "/"); } catch(err) { this._ws_exists = false; return this.log("Error Creating WebSocket: " + err);