Skip to content

Commit

Permalink
Add options as a global variable in the injected page
Browse files Browse the repository at this point in the history
Fix #15.
  • Loading branch information
zalmoxisus committed Nov 19, 2015
1 parent 069df42 commit 9ba546d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
13 changes: 5 additions & 8 deletions src/browser/extension/inject/contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ getOptions(options => {
sendMessage = sendToBg;

let s = document.createElement('script');
s.type = 'text/javascript';
s.appendChild(document.createTextNode('window.devToolsOptions=' + JSON.stringify(options)));
(document.head || document.documentElement).appendChild(s);

s = document.createElement('script');
s.src = chrome.extension.getURL('js/page.bundle.js');
s.onload = function() {
this.parentNode.removeChild(this);
Expand All @@ -42,14 +47,6 @@ getOptions(options => {
if (message.source !== 'redux-page') return;
payload = message.payload;
sendMessage(message);

if (message.init) {
window.postMessage({
type: 'OPTIONS',
options: options,
source: 'redux-cs'
}, '*');
}
}, false);

if (typeof window.onbeforeunload !== 'undefined') {
Expand Down
4 changes: 1 addition & 3 deletions src/browser/extension/inject/pageScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import configureStore from '../../../app/store/configureStore';
import { ACTION, UPDATE, OPTIONS, COMMIT } from '../../../app/constants/ActionTypes';

window.devToolsInit = function(store) {
let options = {};
const options = window.devToolsOptions;
let timeout = { id: null, last: 0};

function doChange(init) {
Expand Down Expand Up @@ -51,8 +51,6 @@ window.devToolsInit = function(store) {
store.liftedStore.dispatch(message.payload);
} else if (message.type === UPDATE) {
onChange();
} else if (message.type === OPTIONS) {
options = message.options;
}

}
Expand Down

0 comments on commit 9ba546d

Please sign in to comment.