From aa41a8caccbe8199f34785ec1bf168bf6e64dd2f Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Mon, 15 Nov 2021 20:21:04 +0300 Subject: initial --- background.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 background.js (limited to 'background.js') 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 -- cgit v1.2.3