From 999be403606241b0b6620453d3ca9a298b6430fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Babi=C4=8D?= Date: Wed, 24 Jun 2020 21:52:20 +0200 Subject: [PATCH] make minimal code work --- _locales/en/messages.json | 9 +++++++++ background.js | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 _locales/en/messages.json create mode 100644 background.js diff --git a/_locales/en/messages.json b/_locales/en/messages.json new file mode 100644 index 0000000..17bc9f5 --- /dev/null +++ b/_locales/en/messages.json @@ -0,0 +1,9 @@ +{"extName": { + "message": "Download Button", + "description": "Extension name"}, + "extDesc": { + "message": "Download Context Menu Button", + "description": "Extension description"}, + "openContextMenuTitle": { + "message": "Download", + "description": "context menu button text"}} diff --git a/background.js b/background.js new file mode 100644 index 0000000..83f0837 --- /dev/null +++ b/background.js @@ -0,0 +1,12 @@ +chrome.contextMenus.onClicked.addListener(function(info) { + // retrieve 311175 from https://openclipart.org/image/400px/311175 + const imageId = info.srcUrl.split('/').pop() + const svgUrl = "https://openclipart.org/download/" + imageId + chrome.downloads.download({url: svgUrl, saveAs: true }, downloadId => console.log(downloadId)) +}); + +chrome.contextMenus.create({ + id: 'open', + title: chrome.i18n.getMessage('openContextMenuTitle'), + contexts: ['link'], +});