Updated to log via the content script, without injecting a tag. Switched to using background/content scripts
Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/e69812c4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/e69812c4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/e69812c4 Branch: refs/heads/SENSSOFT-192 Commit: e69812c44f0ebb35ee61f3216c2a0d7cd48646db Parents: ed63be8 Author: Rob Foley <rob.foley...@gmail.com> Authored: Wed Sep 13 14:18:48 2017 -0700 Committer: Rob Foley <rob.foley...@gmail.com> Committed: Wed Sep 13 14:18:48 2017 -0700 ---------------------------------------------------------------------- src/UserALEWebExtension/globals.js | 10 +++--- src/UserALEWebExtension/manifest.json | 19 ++++------ src/UserALEWebExtension/options.js | 56 ++++++++++++++++-------------- 3 files changed, 41 insertions(+), 44 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/e69812c4/src/UserALEWebExtension/globals.js ---------------------------------------------------------------------- diff --git a/src/UserALEWebExtension/globals.js b/src/UserALEWebExtension/globals.js index 9e560f5..10e05c1 100644 --- a/src/UserALEWebExtension/globals.js +++ b/src/UserALEWebExtension/globals.js @@ -1,10 +1,10 @@ /* eslint-disable */ // these are default values, which can be overridden by the user on the options page -var userAleHost = 'http://localhost:8000'; -var userAleScript = 'userale-0.2.1.min.js'; -var toolUser = 'nobody'; -var toolName = 'test_app'; -var toolVersion = '0.1.0'; +export var userAleHost = 'http://localhost:8000'; +export var userAleScript = 'userale-0.2.1.min.js'; +export var toolUser = 'nobody'; +export var toolName = 'test_app'; +export var toolVersion = '0.1.0'; /* eslint-enable */ http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/e69812c4/src/UserALEWebExtension/manifest.json ---------------------------------------------------------------------- diff --git a/src/UserALEWebExtension/manifest.json b/src/UserALEWebExtension/manifest.json index d0a6688..208f8d4 100644 --- a/src/UserALEWebExtension/manifest.json +++ b/src/UserALEWebExtension/manifest.json @@ -9,27 +9,20 @@ "permissions": [ "activeTab", "storage", - "http://localhost:8080/", - "http://localhost:8000/", - "http://localhost/*", - "http://localhost/", - "*://draperlaboratory.github.io/" - ], - "web_accessible_resources": [ - "userale-0.2.1.min.js" + "tabs" ], + "background": { + "scripts": ["background.js"] + }, "content_scripts": [ { "matches": [ "<all_urls>" ], - "js": [ - "globals.js", - "user-ale-ext.js" - ] + "js": ["content.js"] } ], "options_ui": { - "page": "optionsPage.html" + "page": "optionsPage.html" } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/e69812c4/src/UserALEWebExtension/options.js ---------------------------------------------------------------------- diff --git a/src/UserALEWebExtension/options.js b/src/UserALEWebExtension/options.js index c47ca60..78edc23 100644 --- a/src/UserALEWebExtension/options.js +++ b/src/UserALEWebExtension/options.js @@ -1,46 +1,50 @@ /* eslint-disable */ +import * as globals from './globals.js'; +import * as MessageTypes from './messageTypes.js'; if (chrome) { - browser = chrome; + browser = chrome; } // creates a Future for retrieval of the named keys // the value specified is the default value if one doesn't exist in the storage let store = browser.storage.local.get({ - userAleHost: userAleHost, - userAleScript: userAleScript, - toolUser: toolUser, - toolName: toolName, - toolVersion: toolVersion, + userAleHost: globals.userAleHost, + userAleScript: globals.userAleScript, + toolUser: globals.toolUser, + toolName: globals.toolName, + toolVersion: globals.toolVersion, }, storeCallback); - + function storeCallback(item) { - console.log(item); - document.getElementById("host").value = item.userAleHost; - document.getElementById("clientScript").value = item.userAleScript; - document.getElementById("toolUser").value = item.toolUser; - document.getElementById("toolName").value = item.toolName; - document.getElementById("toolVersion").value = item.toolVersion; + console.log(item); + document.getElementById("host").value = item.userAleHost; + document.getElementById("clientScript").value = item.userAleScript; + document.getElementById("toolUser").value = item.toolUser; + document.getElementById("toolName").value = item.toolName; + document.getElementById("toolVersion").value = item.toolVersion; } - + function onError(error) { - console.log(error); + console.log(error); } function saveOptions(e) { - //e.preventDefault(); - browser.storage.local.set({ - userAleHost: document.getElementById("host").value, - userAleScript: document.getElementById("clientScript").value, - toolUser: document.getElementById("toolUser").value, - toolName: document.getElementById("toolName").value, - toolVersion: document.getElementById("toolVersion").value, - - }); + const updatedConfig = { + userAleHost: document.getElementById("host").value, + userAleScript: document.getElementById("clientScript").value, + toolUser: document.getElementById("toolUser").value, + toolName: document.getElementById("toolName").value, + toolVersion: document.getElementById("toolVersion").value, + }; + + browser.storage.local.set(updatedConfig); + + browser.runtime.sendMessage({ type: MessageTypes.CONFIG_CHANGE, payload: updatedConfig }); } document.addEventListener("submit", function() { - saveOptions(); + saveOptions(); }); -/* eslint-enable */ + /* eslint-enable */