aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--background_scripts/completion_engines.coffee4
-rw-r--r--background_scripts/main.coffee30
-rw-r--r--lib/dom_utils.coffee37
-rw-r--r--lib/utils.coffee10
-rw-r--r--manifest.json2
-rw-r--r--pages/help_dialog.coffee3
-rw-r--r--pages/hud.coffee3
-rw-r--r--pages/logging.coffee1
-rw-r--r--pages/options.coffee1
-rw-r--r--pages/vomnibar.coffee3
-rw-r--r--tests/unit_tests/test_chrome_stubs.coffee2
12 files changed, 82 insertions, 15 deletions
diff --git a/README.md b/README.md
index 85e31b81..2547b978 100644
--- a/README.md
+++ b/README.md
@@ -186,6 +186,7 @@ Release Notes
- 1.60.1: fix [#2642](https://github.com/philc/vimium/issues/2642).
- 1.60.2: revert previous fix for HiDPI screens. This was breaking link-hint positioning for some users.
- 1.60.3: [fix](https://github.com/philc/vimium/pull/2649) link-hint positioning.
+ - 1.60.4: [fix](https://github.com/philc/vimium/pull/2602) hints opening in new tab (Firefox only).
1.59 (2017-04-07)
diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee
index db1ccc77..0a53ad14 100644
--- a/background_scripts/completion_engines.coffee
+++ b/background_scripts/completion_engines.coffee
@@ -48,7 +48,7 @@ class Google extends GoogleXMLBaseEngine
constructor: () ->
super
engineUrl: "https://suggestqueries.google.com/complete/search?ss_protocol=legace&client=toolbar&q=%s"
- regexps: "^https?://[a-z]+\\.google\\.(com|ie|co\\.uk|ca|com\\.au)/"
+ regexps: "^https?://[a-z]+\\.google\\.(com|ie|co\\.(uk|jp)|ca|com\\.au)/"
example:
searchUrl: "https://www.google.com/search?q=%s"
keyword: "g"
@@ -58,7 +58,7 @@ class GoogleMaps extends GoogleXMLBaseEngine
constructor: () ->
super
engineUrl: "https://suggestqueries.google.com/complete/search?ss_protocol=legace&client=toolbar&q=#{@prefix.split(' ').join '+'}%s"
- regexps: "^https?://[a-z]+\\.google\\.(com|ie|co\\.uk|ca|com\\.au)/maps"
+ regexps: "^https?://[a-z]+\\.google\\.(com|ie|co\\.(uk|jp)|ca|com\\.au)/maps"
example:
searchUrl: "https://www.google.com/maps?q=%s"
keyword: "m"
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 379239ae..97d8fa65 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -106,15 +106,25 @@ TabOperations =
index: request.tab.index + 1
active: true
windowId: request.tab.windowId
+ tabConfig.active = request.active if request.active?
# Firefox does not support "about:newtab" in chrome.tabs.create.
delete tabConfig["url"] if tabConfig["url"] == Settings.defaults.newTabUrl
- chrome.tabs.create tabConfig, (tab) ->
- # NOTE(mrmr1993, 2017-02-08): Firefox currently doesn't support openerTabId (issue 1238314) and throws
- # a type error if it is present. We work around this by attempting to set it separately from creating
- # the tab.
- try chrome.tabs.update tab.id, { openerTabId : request.tab.id }, callback
- catch
- callback.apply this, arguments
+
+ # Firefox <57 throws an error when openerTabId is used (issue 1238314).
+ canUseOpenerTabId = not (Utils.isFirefox() and Utils.compareVersions(Utils.firefoxVersion(), "57") < 0)
+ tabConfig.openerTabId = request.tab.id if canUseOpenerTabId
+
+ chrome.tabs.create tabConfig, callback
+
+ # Opens request.url in new window and switches to it.
+ openUrlInNewWindow: (request, callback = (->)) ->
+ winConfig =
+ url: Utils.convertToUrl request.url
+ active: true
+ winConfig.active = request.active if request.active?
+ # Firefox does not support "about:newtab" in chrome.tabs.create.
+ delete tabConfig["url"] if tabConfig["url"] == Settings.defaults.newTabUrl
+ chrome.windows.create winConfig, callback
toggleMuteTab = do ->
muteTab = (tab) -> chrome.tabs.update tab.id, {muted: !tab.mutedInfo.muted}
@@ -252,10 +262,9 @@ selectTab = (direction, {count, tab}) ->
Math.max 0, tabs.length - count
chrome.tabs.update tabs[toSelect].id, active: true
-chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) ->
- return unless changeInfo.status == "loading" # Only do this once per URL change.
+chrome.webNavigation.onCommitted.addListener ({tabId, frameId}) ->
cssConf =
- allFrames: true
+ frameId: frameId
code: Settings.get("userDefinedLinkHintCss")
runAt: "document_start"
chrome.tabs.insertCSS tabId, cssConf, -> chrome.runtime.lastError
@@ -415,6 +424,7 @@ sendRequestHandlers =
# with Chrome-specific URLs like "view-source:http:..".
getCurrentTabUrl: ({tab}) -> tab.url
openUrlInNewTab: (request) -> TabOperations.openUrlInNewTab request
+ openUrlInNewWindow: (request) -> TabOperations.openUrlInNewWindow request
openUrlInIncognito: (request) -> chrome.windows.create incognito: true, url: Utils.convertToUrl request.url
openUrlInCurrentTab: TabOperations.openUrlInCurrentTab
openOptionsPageInNewTab: (request) ->
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index b3fc981b..ff5991dc 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -249,7 +249,11 @@ DomUtils =
simulateClick: (element, modifiers) ->
eventSequence = ["mouseover", "mousedown", "mouseup", "click"]
for event in eventSequence
- @simulateMouseEvent event, element, modifiers
+ defaultActionShouldTrigger = @simulateMouseEvent event, element, modifiers
+ if event == "click" and defaultActionShouldTrigger and Utils.isFirefox()
+ # Firefox doesn't (currently) trigger the default action for modified keys.
+ DomUtils.simulateClickDefaultAction element, modifiers
+ defaultActionShouldTrigger # return the values returned by each @simulateMouseEvent call.
simulateMouseEvent: do ->
lastHoveredElement = undefined
@@ -272,6 +276,29 @@ DomUtils =
# but Webkit will. Dispatching a click on an input box does not seem to focus it; we do that separately
element.dispatchEvent(mouseEvent)
+ simulateClickDefaultAction: (element, modifiers = {}) ->
+ return unless element.tagName?.toLowerCase() == "a" and element.href?
+
+ {ctrlKey, shiftKey, metaKey, altKey} = modifiers
+
+ # Mac uses a different new tab modifier (meta vs. ctrl).
+ if KeyboardUtils.platform == "Mac"
+ newTabModifier = metaKey == true and ctrlKey == false
+ else
+ newTabModifier = metaKey == false and ctrlKey == true
+
+ if newTabModifier
+ # Open in new tab. Shift determines whether the tab is focused when created. Alt is ignored.
+ chrome.runtime.sendMessage {handler: "openUrlInNewTab", url: element.href, active:
+ shiftKey == true}
+ else if shiftKey == true and metaKey == false and ctrlKey == false and altKey == false
+ # Open in new window.
+ chrome.runtime.sendMessage {handler: "openUrlInNewWindow", url: element.href}
+ else if element.target == "_blank"
+ chrome.runtime.sendMessage {handler: "openUrlInNewTab", url: element.href, active: true}
+
+ return
+
addFlashRect: (rect) ->
flashEl = @createElement "div"
flashEl.classList.add "vimiumReset"
@@ -381,5 +408,13 @@ DomUtils =
windowIsTooSmall: ->
return window.innerWidth < 3 or window.innerHeight < 3
+ # Inject user styles manually. This is only necessary for our chrome-extension:// pages and frames.
+ injectUserCss: ->
+ Settings.onLoaded ->
+ style = document.createElement "style"
+ style.type = "text/css"
+ style.textContent = Settings.get "userDefinedLinkHintCss"
+ document.head.appendChild style
+
root = exports ? window
root.DomUtils = DomUtils
diff --git a/lib/utils.coffee b/lib/utils.coffee
index 03dab999..d0a82cf7 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -6,14 +6,22 @@ window.forTrusted ?= (handler) -> (event) ->
else
true
+browserInfo = browser?.runtime?.getBrowserInfo?()
+
Utils =
isFirefox: do ->
# NOTE(mrmr1993): This test only works in the background page, this is overwritten by isEnabledForUrl for
# content scripts.
isFirefox = false
- browser?.runtime?.getBrowserInfo?()?.then? (browserInfo) ->
+ browserInfo?.then? (browserInfo) ->
isFirefox = browserInfo?.name == "Firefox"
-> isFirefox
+ firefoxVersion: do ->
+ # NOTE(mrmr1993): This only works in the background page.
+ ffVersion = undefined
+ browserInfo?.then? (browserInfo) ->
+ ffVersion = browserInfo?.version
+ -> ffVersion
getCurrentVersion: ->
chrome.runtime.getManifest().version
diff --git a/manifest.json b/manifest.json
index 82f07c88..a9629530 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Vimium",
- "version": "1.60.3",
+ "version": "1.60.4",
"description": "The Hacker's Browser. Vimium provides keyboard shortcuts for navigation and control in the spirit of Vim.",
"icons": { "16": "icons/icon16.png",
"48": "icons/icon48.png",
diff --git a/pages/help_dialog.coffee b/pages/help_dialog.coffee
index a0ad1af8..f36155e4 100644
--- a/pages/help_dialog.coffee
+++ b/pages/help_dialog.coffee
@@ -131,6 +131,9 @@ UIComponentServer.registerHandler (event) ->
# Abandon any HUD which might be showing within the help dialog.
HUD.abandon()
+document.addEventListener "DOMContentLoaded", ->
+ DomUtils.injectUserCss() # Manually inject custom user styles.
+
root = exports ? window
root.HelpDialog = HelpDialog
root.isVimiumHelpDialog = true
diff --git a/pages/hud.coffee b/pages/hud.coffee
index ac7059ec..0d2ec2f7 100644
--- a/pages/hud.coffee
+++ b/pages/hud.coffee
@@ -12,6 +12,9 @@ setTextInInputElement = (inputElement, text) ->
selection.removeAllRanges()
selection.addRange range
+document.addEventListener "DOMContentLoaded", ->
+ DomUtils.injectUserCss() # Manually inject custom user styles.
+
document.addEventListener "keydown", (event) ->
inputElement = document.getElementById "hud-find-input"
return unless inputElement? # Don't do anything if we're not in find mode.
diff --git a/pages/logging.coffee b/pages/logging.coffee
index 3ccef4ff..a437b442 100644
--- a/pages/logging.coffee
+++ b/pages/logging.coffee
@@ -1,6 +1,7 @@
$ = (id) -> document.getElementById id
document.addEventListener "DOMContentLoaded", ->
+ DomUtils.injectUserCss() # Manually inject custom user styles.
$("vimiumVersion").innerText = Utils.getCurrentVersion()
chrome.storage.local.get "installDate", (items) ->
diff --git a/pages/options.coffee b/pages/options.coffee
index 19330271..035dd403 100644
--- a/pages/options.coffee
+++ b/pages/options.coffee
@@ -311,6 +311,7 @@ initPopupPage = ->
#
# Initialization.
document.addEventListener "DOMContentLoaded", ->
+ DomUtils.injectUserCss() # Manually inject custom user styles.
xhr = new XMLHttpRequest()
xhr.open 'GET', chrome.extension.getURL('pages/exclusions.html'), true
xhr.onreadystatechange = ->
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee
index 071604b7..8c790ca8 100644
--- a/pages/vomnibar.coffee
+++ b/pages/vomnibar.coffee
@@ -335,5 +335,8 @@ UIComponentServer.registerHandler (event) ->
when "hidden" then Vomnibar.onHidden()
when "activate" then Vomnibar.activate event.data
+document.addEventListener "DOMContentLoaded", ->
+ DomUtils.injectUserCss() # Manually inject custom user styles.
+
root = exports ? window
root.Vomnibar = Vomnibar
diff --git a/tests/unit_tests/test_chrome_stubs.coffee b/tests/unit_tests/test_chrome_stubs.coffee
index 53ca805d..44ec4f66 100644
--- a/tests/unit_tests/test_chrome_stubs.coffee
+++ b/tests/unit_tests/test_chrome_stubs.coffee
@@ -60,6 +60,8 @@ exports.chrome =
addListener: () ->
onReferenceFragmentUpdated:
addListener: () ->
+ onCommitted:
+ addListener: () ->
windows:
onRemoved: