diff --git a/firefox-mv2/background.html b/firefox-mv2/background.html index 0c861d6..07bb46c 100644 --- a/firefox-mv2/background.html +++ b/firefox-mv2/background.html @@ -3,5 +3,6 @@ + diff --git a/firefox-mv2/create-menus.js b/firefox-mv2/create-menus.js new file mode 100644 index 0000000..fe1d4cb --- /dev/null +++ b/firefox-mv2/create-menus.js @@ -0,0 +1,37 @@ +// This file is a workaround for Firefox event page. +// It is executed every time background.js is loaded. +// +// In Chrome/Chromium, browsers, the suggested way to create a context menu is calling +// `chrome.contextMenu.create()` in `chrome.runtime.onInstalled()`. This function will be called +// when browser is restarted. +// +// In Firefox, the behavior is slightly different, such that onInstalled() is called ONLY at the +// first time the add-on is installed. It is NOT called when the browser is restarted. +// +// As a workaround, in Firefox, call contextMenus.create() everytime background.js is loaded. +// +// For more details, see the following issues on Firefox's bug tracker: +// +// * https://bugzilla.mozilla.org/show_bug.cgi?id=1567467 +// * https://bugzilla.mozilla.org/show_bug.cgi?id=1558336 + +chrome.contextMenus.create({ + id: 'current-page', + title: 'Copy [Page Title](URL)', + type: 'normal', + contexts: ['page'], +}); + +chrome.contextMenus.create({ + id: 'link', + title: 'Copy [Link Content](URL)', + type: 'normal', + contexts: ['link'], +}); + +chrome.contextMenus.create({ + id: 'image', + title: 'Copy ![](Image URL)', // TODO: how to fetch alt text? + type: 'normal', + contexts: ['image'], +}); diff --git a/firefox-mv2/manifest.json b/firefox-mv2/manifest.json index 43063af..a123184 100644 --- a/firefox-mv2/manifest.json +++ b/firefox-mv2/manifest.json @@ -1,6 +1,6 @@ { "name": "Copy as Markdown", - "version": "2.6.0", + "version": "2.6.2rc1", "manifest_version": 2, "description": "Copy Link or Image as Markdown code", "permissions": [