From b8893839ae79497e1b736d5ce7a28aaff491fa5a Mon Sep 17 00:00:00 2001 From: dseabolt Date: Tue, 10 Sep 2019 10:56:36 -0600 Subject: [PATCH 1/4] Making changes to not crash on a redirect and to capture all traffic to other environments --- browser.js | 5 ++++- manifest_unityclient.json | 4 +++- parseSettings.js | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/browser.js b/browser.js index 739348b..4547161 100644 --- a/browser.js +++ b/browser.js @@ -206,7 +206,10 @@ function handleLoadRedirect(event) { return; } - document.querySelector('#location').value = event.newUrl; + var location = document.querySelector('#location'); + if(location !== null){ + location.value = event.newUrl; + } } function handleNewWindow(event) { diff --git a/manifest_unityclient.json b/manifest_unityclient.json index dfb90cb..984e288 100644 --- a/manifest_unityclient.json +++ b/manifest_unityclient.json @@ -51,7 +51,9 @@ "url_handlers": { "app.imaginelearning.com": { "matches": [ - "https://app.imaginelearning.com/*" + "https://app.imaginelearning.com/*", + "https://testapp.imaginelearning.com/*", + "https://rcapp.imaginelearning.com/*" ], "title": "Open Imagine Learning" } diff --git a/parseSettings.js b/parseSettings.js index 1c6afbe..111f56c 100644 --- a/parseSettings.js +++ b/parseSettings.js @@ -27,6 +27,8 @@ function convertServerSettingsToUrl(serverSettings, launchUrl) { if (serverSettings.env) { queryString.push('env=' + serverSettings.env); } + + queryString.push('chromeApp'); } //if no environment set then default to production @@ -38,6 +40,5 @@ function convertServerSettingsToUrl(serverSettings, launchUrl) { } url += (url.indexOf('?') < 0 ? '?' : '&') + queryString.join('&'); - return url; } From eb34561b3bec182bce55a148e61063fce2a7c700 Mon Sep 17 00:00:00 2001 From: dseabolt Date: Fri, 13 Sep 2019 19:21:57 -0600 Subject: [PATCH 2/4] Removing multi-domain support --- manifest_unityclient.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/manifest_unityclient.json b/manifest_unityclient.json index 984e288..dfb90cb 100644 --- a/manifest_unityclient.json +++ b/manifest_unityclient.json @@ -51,9 +51,7 @@ "url_handlers": { "app.imaginelearning.com": { "matches": [ - "https://app.imaginelearning.com/*", - "https://testapp.imaginelearning.com/*", - "https://rcapp.imaginelearning.com/*" + "https://app.imaginelearning.com/*" ], "title": "Open Imagine Learning" } From 7886b5bc70cb594b1d898e9f4c2f993f36a00a3f Mon Sep 17 00:00:00 2001 From: dseabolt Date: Mon, 16 Sep 2019 13:18:55 -0600 Subject: [PATCH 3/4] Renaming the query parameter, and not applying it only when server settings are applied --- parseSettings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parseSettings.js b/parseSettings.js index 111f56c..835d6ef 100644 --- a/parseSettings.js +++ b/parseSettings.js @@ -27,8 +27,6 @@ function convertServerSettingsToUrl(serverSettings, launchUrl) { if (serverSettings.env) { queryString.push('env=' + serverSettings.env); } - - queryString.push('chromeApp'); } //if no environment set then default to production @@ -39,6 +37,8 @@ function convertServerSettingsToUrl(serverSettings, launchUrl) { queryString.push('env=production'); } + queryString.push('platform=chromeApp'); + url += (url.indexOf('?') < 0 ? '?' : '&') + queryString.join('&'); return url; } From 64dff26711e0e56b774e665c2d0148eb359b22ef Mon Sep 17 00:00:00 2001 From: dseabolt Date: Fri, 20 Sep 2019 11:20:42 -0600 Subject: [PATCH 4/4] Removing the auto included env query parameter since the login page will now provided it by default. Added in messaging to allow refreshing the webview if we relaunch the app --- background.js | 5 +++++ browser.js | 3 +++ parseSettings.js | 9 --------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/background.js b/background.js index 818a5b1..1aeb494 100644 --- a/background.js +++ b/background.js @@ -220,6 +220,11 @@ function launch(launchData) { chrome.storage.local.remove('relativeLaunchUrl', launchApp); } + // If we are relaunching the app, inform the webview so it'll start again. + if(window.app && relativeUrl) { + chrome.runtime.sendMessage({command: "restart"}, (response) => {}); + } + function launchApp() { var info = { type: 'onLaunched', diff --git a/browser.js b/browser.js index 4547161..f388ee1 100644 --- a/browser.js +++ b/browser.js @@ -275,7 +275,10 @@ function handleMessage(message, sender, sendResponse) { }); }); return !!sendResponse; // wait for response + } else if (message.command === 'restart') { + onload(); } } chrome.runtime.onMessageExternal.addListener(handleMessage); +chrome.runtime.onMessage.addListener(handleMessage); diff --git a/parseSettings.js b/parseSettings.js index 835d6ef..e3e64e3 100644 --- a/parseSettings.js +++ b/parseSettings.js @@ -28,15 +28,6 @@ function convertServerSettingsToUrl(serverSettings, launchUrl) { queryString.push('env=' + serverSettings.env); } } - - //if no environment set then default to production - var envIndex = queryString.findIndex(function(item) { - return /^env=/.test(item); - }); - if (envIndex < 0) { - queryString.push('env=production'); - } - queryString.push('platform=chromeApp'); url += (url.indexOf('?') < 0 ? '?' : '&') + queryString.join('&');