From a898e487a7a4c3471edcacc424916db5ec28fdd4 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Sun, 17 Feb 2013 01:39:42 +0000 Subject: Added feature to download links --- background_scripts/commands.coffee | 5 ++++- content_scripts/link_hints.coffee | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 4b3130c8..45a220dc 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -110,7 +110,7 @@ Commands = # from Vimium will uncover these gems. advancedCommands: [ "scrollToLeft", "scrollToRight", "moveTabToNewWindow", - "goUp", "goToRoot", "focusInput", "LinkHints.activateModeWithQueue", + "goUp", "goToRoot", "focusInput", "LinkHints.activateModeWithQueue", "LinkHints.activateModeToDownloadLink", "LinkHints.activateModeToOpenIncognito", "goNext", "goPrevious", "Marks.activateCreateMode", "Marks.activateGotoMode", "moveTabLeft", "moveTabRight", "closeTabsOnLeft","closeTabsOnRight", "closeOtherTabs"] @@ -146,6 +146,8 @@ defaultKeyMappings = "F": "LinkHints.activateModeToOpenInNewTab" "": "LinkHints.activateModeWithQueue" + "af": "LinkHints.activateModeToDownloadLink" + "/": "enterFindMode" "n": "performFind" "N": "performBackwardsFind" @@ -228,6 +230,7 @@ commandDescriptions = "LinkHints.activateModeToOpenIncognito": ["Open a link in incognito window"] + "LinkHints.activateModeToDownloadLink": ["Download link url"] enterFindMode: ["Enter find mode"] performFind: ["Cycle forward to the next find match"] performBackwardsFind: ["Cycle backward to the previous find match"] diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 24314b26..1cba822d 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -14,6 +14,7 @@ OPEN_IN_NEW_FG_TAB = {} OPEN_WITH_QUEUE = {} COPY_LINK_URL = {} OPEN_INCOGNITO = {} +DOWNLOAD_LINK_URL = {} LinkHints = hintMarkerContainingDiv: null @@ -52,6 +53,7 @@ LinkHints = activateModeToCopyLinkUrl: -> @activateMode(COPY_LINK_URL) activateModeWithQueue: -> @activateMode(OPEN_WITH_QUEUE) activateModeToOpenIncognito: -> @activateMode(OPEN_INCOGNITO) + activateModeToDownloadLink: -> @activateMode(DOWNLOAD_LINK_URL) activateMode: (mode = OPEN_IN_CURRENT_TAB) -> # we need documentElement to be ready in order to append links @@ -93,7 +95,8 @@ LinkHints = DomUtils.simulateClick(link, { shiftKey: @mode is OPEN_IN_NEW_FG_TAB, metaKey: KeyboardUtils.platform == "Mac", - ctrlKey: KeyboardUtils.platform != "Mac" }) + ctrlKey: KeyboardUtils.platform != "Mac", + altKey: false}) else if @mode is COPY_LINK_URL HUD.show("Copy link URL to Clipboard") @linkActivator = (link) -> @@ -105,6 +108,13 @@ LinkHints = chrome.runtime.sendMessage( handler: 'openUrlInIncognito' url: link.href) + else if @mode is DOWNLOAD_LINK_URL + HUD.show("Download link URL") + @linkActivator = (link) -> + DomUtils.simulateClick(link, { + altKey: KeyboardUtils.platform == "Mac", + ctrlKey: false, + metaKey: false }) else # OPEN_IN_CURRENT_TAB HUD.show("Open link in current tab") @linkActivator = (link) -> DomUtils.simulateClick.bind(DomUtils, link)() -- cgit v1.2.3 From 238893e6cf02dbdfb85d274f77368dbd7d039a3d Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Thu, 21 Aug 2014 13:23:25 +0300 Subject: Update link_hints.coffee --- content_scripts/link_hints.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 1cba822d..24bd7126 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -112,7 +112,7 @@ LinkHints = HUD.show("Download link URL") @linkActivator = (link) -> DomUtils.simulateClick(link, { - altKey: KeyboardUtils.platform == "Mac", + altKey: true, ctrlKey: false, metaKey: false }) else # OPEN_IN_CURRENT_TAB -- cgit v1.2.3