summaryrefslogtreecommitdiff
path: root/background.js
diff options
context:
space:
mode:
Diffstat (limited to 'background.js')
-rw-r--r--background.js19
1 files changed, 19 insertions, 0 deletions
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