Updated to use messaging to pass logs to background extension, to sidestep https rules in content script
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/ce10df83 Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/ce10df83 Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/ce10df83 Branch: refs/heads/SENSSOFT-192 Commit: ce10df83c8ffe157d4729243c6de1c1cf874762c Parents: 6e452fe Author: Rob Foley <rob.foley...@gmail.com> Authored: Mon Sep 18 17:16:20 2017 -0400 Committer: Rob Foley <rob.foley...@gmail.com> Committed: Mon Sep 18 17:16:20 2017 -0400 ---------------------------------------------------------------------- src/UserALEWebExtension/background.js | 27 ++++++++++++++++++--------- src/UserALEWebExtension/content.js | 13 +++++++++---- 2 files changed, 27 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/ce10df83/src/UserALEWebExtension/background.js ---------------------------------------------------------------------- diff --git a/src/UserALEWebExtension/background.js b/src/UserALEWebExtension/background.js index 4c813cf..d98304f 100644 --- a/src/UserALEWebExtension/background.js +++ b/src/UserALEWebExtension/background.js @@ -80,16 +80,25 @@ function packageBrowserLog(type, logDetail) { browser.runtime.onMessage.addListener(function (message) { switch (message.type) { case MessageTypes.CONFIG_CHANGE: - const updatedConfig = Object.assign({}, config, { - url: message.payload.userAleHost, - userId: message.payload.toolUser, - toolName: message.payload.toolName, - toolVersion: message.payload.toolVersion - }); - initPackager(logs, updatedConfig); - initSender(logs, updatedConfig); - dispatchTabMessage(message); + (function () { + const updatedConfig = Object.assign({}, config, { + url: message.payload.userAleHost, + userId: message.payload.toolUser, + toolName: message.payload.toolName, + toolVersion: message.payload.toolVersion + }); + initPackager(logs, updatedConfig); + initSender(logs, updatedConfig); + dispatchTabMessage(message); + })(); break; + + case MessageTypes.ADD_LOG: + (function () { + logs.push(message.payload); + })(); + break; + default: console.log('got unknown message type ', message); } http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/ce10df83/src/UserALEWebExtension/content.js ---------------------------------------------------------------------- diff --git a/src/UserALEWebExtension/content.js b/src/UserALEWebExtension/content.js index 7dfd37c..6397311 100644 --- a/src/UserALEWebExtension/content.js +++ b/src/UserALEWebExtension/content.js @@ -4,7 +4,7 @@ import * as globals from './globals'; import * as MessageTypes from './messageTypes.js'; -import { map, options, start } from '../main.js'; +import { filter, options, start } from '../main.js'; // browser is defined in firefox, but not in chrome. In chrome, they use // the 'chrome' global instead. Let's map it to browser so we don't have @@ -33,13 +33,18 @@ function storeCallback(item) { }); } +function queueLog(log) { + browser.runtime.sendMessage({ type: MessageTypes.ADD_LOG, payload: log }); +} + function injectScript(config) { options(config); start(); - map(function(log) { - return Object.assign({}, log, { + filter(function (log) { + queueLog(Object.assign({}, log, { pageUrl: document.location.href, - }); + })); + return false; }); }