From 68270310c7ed7d292009b4d364ee989882a42e63 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Fri, 6 Sep 2019 14:37:39 +0300 Subject: [PATCH] web: parse host query via browser api, logging --- code/html/custom.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/code/html/custom.js b/code/html/custom.js index 825c252a..5bcb1f28 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -1861,9 +1861,11 @@ function connectToCurrentURL() { connectToURL(new URL(window.location)); } -function getParameterByName(name) { - var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search); - return match && decodeURIComponent(match[1].replace(/\+/g, ' ')); +function enableWSLogging() { + var processDataOrig = window.processData; + window.processData = function(data) { console.log(data); processDataOrig(data); } + var sendActionOrig = window.sendAction; + window.sendAction = function(action, data) { console.log(action,data); sendActionOrig(action, data);} } $(function() { @@ -1944,7 +1946,10 @@ $(function() { if (window.location.protocol === "file:") { return; } // Check host param in query string - if (host = getParameterByName('host')) { + var search = new URLSearchParams(window.location.search), + host = search.get("host"); + + if (host !== null) { connect(host); } else { connectToCurrentURL();