Kill more globals

This commit is contained in:
eight 2018-10-11 01:26:24 +08:00
parent dc491e9be3
commit 43db875fd8
4 changed files with 32 additions and 32 deletions

View File

@ -1,9 +1,6 @@
/* /* global detectSloppyRegexps download prefs openURL FIREFOX CHROME VIVALDI
global handleCssTransitionBug detectSloppyRegexps openEditor debounce URLS ignoreChromeError queryTabs getTab
global openEditor usercss styleManager db msg navigatorUtil
global styleViaAPI
global loadScript
global usercss styleManager db msg navigatorUtil
*/ */
'use strict'; 'use strict';
@ -65,32 +62,32 @@ var browserCommands, contextMenus;
// register all listeners // register all listeners
msg.on(onRuntimeMessage); msg.on(onRuntimeMessage);
if (FIREFOX) { // if (FIREFOX) {
// see notes in apply.js for getStylesFallback // see notes in apply.js for getStylesFallback
const MSG_GET_STYLES = 'getStyles:'; // const MSG_GET_STYLES = 'getStyles:';
const MSG_GET_STYLES_LEN = MSG_GET_STYLES.length; // const MSG_GET_STYLES_LEN = MSG_GET_STYLES.length;
chrome.runtime.onConnect.addListener(port => { // chrome.runtime.onConnect.addListener(port => {
if (!port.name.startsWith(MSG_GET_STYLES)) return; // if (!port.name.startsWith(MSG_GET_STYLES)) return;
const tabId = port.sender.tab.id; // const tabId = port.sender.tab.id;
const frameId = port.sender.frameId; // const frameId = port.sender.frameId;
const options = tryJSONparse(port.name.slice(MSG_GET_STYLES_LEN)); // const options = tryJSONparse(port.name.slice(MSG_GET_STYLES_LEN));
port.disconnect(); // port.disconnect();
// FIXME: getStylesFallback? // FIXME: getStylesFallback?
getStyles(options).then(styles => { // getStyles(options).then(styles => {
if (!styles.length) return; // if (!styles.length) return;
chrome.tabs.executeScript(tabId, { // chrome.tabs.executeScript(tabId, {
code: ` // code: `
applyOnMessage({ // applyOnMessage({
method: 'styleApply', // method: 'styleApply',
styles: ${JSON.stringify(styles)}, // styles: ${JSON.stringify(styles)},
}) // })
`, // `,
runAt: 'document_start', // runAt: 'document_start',
frameId, // frameId,
}); // });
}); // });
}); // });
} // }
navigatorUtil.onUrlChange(({tabId, frameId}, type) => { navigatorUtil.onUrlChange(({tabId, frameId}, type) => {
if (type === 'committed') { if (type === 'committed') {

View File

@ -1,3 +1,5 @@
/* global tryCatch chromeLocal ignoreChromeError */
/* exported db */
'use strict'; 'use strict';
const db = (() => { const db = (() => {

View File

@ -1,4 +1,5 @@
/* global promisify */ /* global promisify CHROME URLS */
/* exported navigatorUtil */
'use strict'; 'use strict';
const navigatorUtil = (() => { const navigatorUtil = (() => {

View File

@ -1,4 +1,4 @@
/* global importScripts parserlib CSSLint parseMozFormat */ /* global importScripts parserlib parseMozFormat */
'use strict'; 'use strict';
importScripts('/vendor-overwrites/csslint/parserlib.js', '/js/moz-parser.js'); importScripts('/vendor-overwrites/csslint/parserlib.js', '/js/moz-parser.js');