This commit is contained in:
Evgeny Zinoviev 2021-11-15 20:21:04 +03:00
commit aa41a8cacc
3 changed files with 30 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.zip
/.idea

19
background.js Normal file
View File

@ -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
})

9
manifest.json Normal file
View File

@ -0,0 +1,9 @@
{
"manifest_version": 2,
"name": "Save images to Downloads",
"version": "1.0",
"background": {
"scripts": ["background.js"]
},
"permissions": ["downloads", "contextMenus"]
}