From 43db875fd80ec851f1d72ad5589e39126a8d6391 Mon Sep 17 00:00:00 2001 From: eight Date: Thu, 11 Oct 2018 01:26:24 +0800 Subject: [PATCH] Kill more globals --- background/background.js | 57 ++++++++++++++++------------------ background/db.js | 2 ++ background/navigator-util.js | 3 +- background/parserlib-loader.js | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/background/background.js b/background/background.js index 050bfdc8..522e298c 100644 --- a/background/background.js +++ b/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'; @@ -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') { diff --git a/background/db.js b/background/db.js index 6d38a9fb..0347db46 100644 --- a/background/db.js +++ b/background/db.js @@ -1,3 +1,5 @@ +/* global tryCatch chromeLocal ignoreChromeError */ +/* exported db */ 'use strict'; const db = (() => { diff --git a/background/navigator-util.js b/background/navigator-util.js index fe573049..fb91d65c 100644 --- a/background/navigator-util.js +++ b/background/navigator-util.js @@ -1,4 +1,5 @@ -/* global promisify */ +/* global promisify CHROME URLS */ +/* exported navigatorUtil */ 'use strict'; const navigatorUtil = (() => { diff --git a/background/parserlib-loader.js b/background/parserlib-loader.js index 8275e8fd..cf5ec6e6 100644 --- a/background/parserlib-loader.js +++ b/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');