diff options
| author | mrmr1993 | 2017-08-15 19:53:35 +0100 | 
|---|---|---|
| committer | mrmr1993 | 2017-09-21 20:35:59 +0100 | 
| commit | e6a529ea00033d44226581c48df4e84f4cb80237 (patch) | |
| tree | 85bb56abb0b75087136e68762829c61c8e9da046 | |
| parent | 4099067f7c03551bea20b6cf6504e4c15d6e7506 (diff) | |
| download | vimium-e6a529ea00033d44226581c48df4e84f4cb80237.tar.bz2 | |
FF: Simulate default action for clicking links with link hints
| -rw-r--r-- | background_scripts/main.coffee | 1 | ||||
| -rw-r--r-- | content_scripts/link_hints.coffee | 12 | 
2 files changed, 12 insertions, 1 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 379239ae..eeda263a 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -106,6 +106,7 @@ 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) -> diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index eeadfc0c..f06ef786 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -11,6 +11,7 @@  # The "name" property below is a short-form name to appear in the link-hints mode's name.  It's for debug only.  #  isMac = KeyboardUtils.platform == "Mac" +simulateClickDefaultAction = true  OPEN_IN_CURRENT_TAB =    name: "curr-tab"    indicator: "Open link in current tab" @@ -384,7 +385,16 @@ class LinkHintsMode              window.focus()              DomUtils.simulateSelect clickEl            else -            clickActivator = (modifiers) -> (link) -> DomUtils.simulateClick link, modifiers +            clickActivator = (modifiers) -> (link) -> +              defaultActionsTriggered = DomUtils.simulateClick link, modifiers +              if simulateClickDefaultAction and +                  defaultActionsTriggered[3] and link.tagName?.toLowerCase() == "a" and +                  modifiers? and modifiers.metaKey == isMac and modifiers.ctrlKey == not isMac +              # We've clicked a link that *should* open in a new tab. If simulateClickDefaultAction is true, +              # we assume the popup-blocker is active, and simulate opening the new tab ourselves. +                chrome.runtime.sendMessage {handler: "openUrlInNewTab", url: link.href, active: +                  modifiers.shiftKey == true} +              linkActivator = @mode.linkActivator ? clickActivator @mode.clickModifiers              # TODO: Are there any other input elements which should not receive focus?              if clickEl.nodeName.toLowerCase() in ["input", "select"] and clickEl.type not in ["button", "submit"] | 
