Skip to content

Commit

Permalink
Kill more globals
Browse files Browse the repository at this point in the history
  • Loading branch information
eight04 committed Oct 10, 2018
1 parent dc491e9 commit 43db875
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
57 changes: 27 additions & 30 deletions background/background.js
@@ -1,9 +1,6 @@
/*
global handleCssTransitionBug detectSloppyRegexps
global openEditor
global styleViaAPI
global loadScript
global usercss styleManager db msg navigatorUtil
/* global detectSloppyRegexps download prefs openURL FIREFOX CHROME VIVALDI
openEditor debounce URLS ignoreChromeError queryTabs getTab
usercss styleManager db msg navigatorUtil
*/
'use strict';

Expand Down Expand Up @@ -65,32 +62,32 @@ var browserCommands, contextMenus;
// register all listeners
msg.on(onRuntimeMessage);

if (FIREFOX) {
// if (FIREFOX) {
// see notes in apply.js for getStylesFallback
const MSG_GET_STYLES = 'getStyles:';
const MSG_GET_STYLES_LEN = MSG_GET_STYLES.length;
chrome.runtime.onConnect.addListener(port => {
if (!port.name.startsWith(MSG_GET_STYLES)) return;
const tabId = port.sender.tab.id;
const frameId = port.sender.frameId;
const options = tryJSONparse(port.name.slice(MSG_GET_STYLES_LEN));
port.disconnect();
// const MSG_GET_STYLES = 'getStyles:';
// const MSG_GET_STYLES_LEN = MSG_GET_STYLES.length;
// chrome.runtime.onConnect.addListener(port => {
// if (!port.name.startsWith(MSG_GET_STYLES)) return;
// const tabId = port.sender.tab.id;
// const frameId = port.sender.frameId;
// const options = tryJSONparse(port.name.slice(MSG_GET_STYLES_LEN));
// port.disconnect();
// FIXME: getStylesFallback?
getStyles(options).then(styles => {
if (!styles.length) return;
chrome.tabs.executeScript(tabId, {
code: `
applyOnMessage({
method: 'styleApply',
styles: ${JSON.stringify(styles)},
})
`,
runAt: 'document_start',
frameId,
});
});
});
}
// getStyles(options).then(styles => {
// if (!styles.length) return;
// chrome.tabs.executeScript(tabId, {
// code: `
// applyOnMessage({
// method: 'styleApply',
// styles: ${JSON.stringify(styles)},
// })
// `,
// runAt: 'document_start',
// frameId,
// });
// });
// });
// }

navigatorUtil.onUrlChange(({tabId, frameId}, type) => {
if (type === 'committed') {
Expand Down
2 changes: 2 additions & 0 deletions background/db.js
@@ -1,3 +1,5 @@
/* global tryCatch chromeLocal ignoreChromeError */
/* exported db */
'use strict';

const db = (() => {
Expand Down
3 changes: 2 additions & 1 deletion background/navigator-util.js
@@ -1,4 +1,5 @@
/* global promisify */
/* global promisify CHROME URLS */
/* exported navigatorUtil */
'use strict';

const navigatorUtil = (() => {
Expand Down
2 changes: 1 addition & 1 deletion background/parserlib-loader.js
@@ -1,4 +1,4 @@
/* global importScripts parserlib CSSLint parseMozFormat */
/* global importScripts parserlib parseMozFormat */
'use strict';

importScripts('/vendor-overwrites/csslint/parserlib.js', '/js/moz-parser.js');
Expand Down

0 comments on commit 43db875

Please sign in to comment.