diff --git a/background_scripts/actions.js b/background_scripts/actions.js index 96b8591b..4feac212 100644 --- a/background_scripts/actions.js +++ b/background_scripts/actions.js @@ -85,6 +85,11 @@ Actions = (function() { } }; + _.saveImage = function(o) { + var filename = o.url.replace(/(.*\/|\?.*)/g, '') + chrome.downloads.download({ url: o.url, filename: filename, saveAs: false }); + }; + _.addFrame = function(o) { Frames.add(o.sender.tab.id, o.port, o.request.isCommandFrame); }; diff --git a/content_scripts/hints.js b/content_scripts/hints.js index ad6556b6..b83d3ccc 100644 --- a/content_scripts/hints.js +++ b/content_scripts/hints.js @@ -140,6 +140,9 @@ Hints.dispatchAction = function(link, shift) { case 'fullimage': RUNTIME('openLinkTab', {active: false, url: link.src, noconvert: true}); break; + case 'saveimage': + RUNTIME('saveImage', {url: link.src,}); + break; case 'image': case 'multiimage': var url = 'https://www.google.com/searchbyimage?image_url=' + link.src; @@ -739,6 +742,7 @@ Hints.create = function(type, multi) { multiyank: '(multi-yank)', image: '(reverse-image)', fullimage: '(full image)', + saveimage: '(save image)', tabbed: '(tabbed)', tabbedActive: '(tabbed)', window: '(window)', diff --git a/content_scripts/mappings.js b/content_scripts/mappings.js index a7de76f6..769c28d1 100644 --- a/content_scripts/mappings.js +++ b/content_scripts/mappings.js @@ -438,6 +438,7 @@ Mappings.actions = { yankUrl: function() { Hints.create('yank'); }, multiYankUrl: function() { Hints.create('multiyank'); }, fullImageHint: function() { Hints.create('fullimage'); }, + saveImageHint: function() { Hints.create('saveimage'); }, yankDocumentUrl: function() { RUNTIME('getRootUrl', function(url) { Clipboard.copy(url);