make minimal code work

master
Peter Babič 3 years ago
parent b0cd19aefd
commit 999be40360
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 9
      _locales/en/messages.json
  2. 12
      background.js

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

@ -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'],
});
Loading…
Cancel
Save