diff options
| author | Stephen Blott | 2015-03-08 10:43:53 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2015-03-08 10:43:53 +0000 | 
| commit | d3cd1fd3d0f8b2cc4249ad8fdbd76bbb94a82997 (patch) | |
| tree | 20958fd64c38a60fde1e4da447132486a4d76dd0 | |
| parent | b05276ed8264e5a71f20a7068690ba2a414ee6d8 (diff) | |
| download | vimium-d3cd1fd3d0f8b2cc4249ad8fdbd76bbb94a82997.tar.bz2 | |
Reload content scripts: minor refactoring.
| -rw-r--r-- | background_scripts/main.coffee | 20 | 
1 files changed, 8 insertions, 12 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 7b360efd..4ab88019 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -1,26 +1,22 @@  root = exports ? window -currentVersion = Utils.getCurrentVersion() - -# Iterate over existing tabs and inject the necessary javascript/css into each. -injectContentScriptsIntoOpenTabs = -> +# The browser may have tabs already open. We inject the content scripts immediately so that they work straight +# away. +chrome.runtime.onInstalled.addListener ->    manifest = chrome.runtime.getManifest()    # Content scripts loaded on every page should be in the same group. We assume it is the first.    contentScripts = manifest.content_scripts[0] +  jobs = [ [ chrome.tabs.executeScript, contentScripts.js ], [ chrome.tabs.insertCSS, contentScripts.css ] ] +  # Chrome complains if we don't evaluate chrome.runtime.lastError on errors (and we get errors for tabs on +  # which Vimium cannot run). +  checkLastRuntimeError = -> chrome.runtime.lastError    chrome.tabs.query { status: "complete" }, (tabs) -> -    jobs = [ [ chrome.tabs.executeScript, contentScripts.js ], [ chrome.tabs.insertCSS, contentScripts.css ] ] -    # Chrome complains if we don't evaluate chrome.runtime.lastError on errors (and we get errors for tabs on -    # which Vimium cannot run). -    checkLastRuntimeError = -> chrome.runtime.lastError      for tab in tabs        for [ func, files ] in jobs          for file in files            func tab.id, { file: file, allFrames: contentScripts.allFrames }, checkLastRuntimeError -# The browser may have tabs already open. We inject the content scripts immediately so that they work straight -# away. -chrome.runtime.onInstalled.addListener injectContentScriptsIntoOpenTabs - +currentVersion = Utils.getCurrentVersion()  tabQueue = {} # windowId -> Array  tabInfoMap = {} # tabId -> object with various tab properties  keyQueue = "" # Queue of keys typed | 
