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 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') {

View File

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

View File

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

View File

@ -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');