diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | background.js | 19 | ||||
-rw-r--r-- | manifest.json | 9 |
3 files changed, 30 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7609906 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.zip +/.idea diff --git a/background.js b/background.js new file mode 100644 index 0000000..a806e71 --- /dev/null +++ b/background.js @@ -0,0 +1,19 @@ +function downloadResource(info, tab) { + let url = info['srcUrl'] + + let filename = url.substring(url.lastIndexOf('/')+1) + if (filename.indexOf('?') !== false) + filename = filename.substring(0, filename.indexOf('?')) + + chrome.downloads.download({ + url, + filename, + saveAs: false + }) +} + +chrome.contextMenus.create({ + "title": "Save to Downloads…", + "contexts": ["image"], + "onclick": downloadResource +})
\ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..a1a89d4 --- /dev/null +++ b/manifest.json @@ -0,0 +1,9 @@ +{ + "manifest_version": 2, + "name": "Save images to Downloads", + "version": "1.0", + "background": { + "scripts": ["background.js"] + }, + "permissions": ["downloads", "contextMenus"] +}
\ No newline at end of file |