diff options
| author | Stephen Blott | 2015-03-08 10:47:02 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-03-08 10:47:02 +0000 |
| commit | fabe391e80e9f90b656786fb58795b9769457253 (patch) | |
| tree | 1ece3bdff028fc839c5bf6da388e41939fd91274 /background_scripts | |
| parent | e49b701fb813e147a187058fe7eda4bfa2d40bec (diff) | |
| parent | b15d5231e1660aff220885a3feab62eaa5b9861d (diff) | |
| download | vimium-fabe391e80e9f90b656786fb58795b9769457253.tar.bz2 | |
Merge branch 'mrmr1993-loadScriptsOnUpdate'
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/main.coffee | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 23950e6e..4ab88019 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -1,7 +1,22 @@ root = exports ? window -currentVersion = Utils.getCurrentVersion() +# 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) -> + for tab in tabs + for [ func, files ] in jobs + for file in files + func tab.id, { file: file, allFrames: contentScripts.allFrames }, checkLastRuntimeError +currentVersion = Utils.getCurrentVersion() tabQueue = {} # windowId -> Array tabInfoMap = {} # tabId -> object with various tab properties keyQueue = "" # Queue of keys typed |
