diff --git a/background.js b/background.js new file mode 100644 index 0000000..c9fc69d --- /dev/null +++ b/background.js @@ -0,0 +1,20 @@ +browser.runtime.onInstalled.addListener(() => { + browser.contextMenus.create({ + id: 'openInMantis', + title: 'Open in Mantis', + contexts: ['selection'] + }); +}); + +browser.contextMenus.onClicked.addListener(async (info) => { + if (info.menuItemId === 'openInMantis') { + let selectedText = info.selectionText; + if (selectedText.startsWith('#')) { + selectedText = selectedText.substring(1); + } + const result = await browser.storage.sync.get(['customUrl']); + const fixedUrl = result.customUrl || 'https://example.com/view.php?id='; + const completeUrl = `${fixedUrl}${selectedText}`; + await browser.tabs.create({ url: completeUrl }); + } +}); diff --git a/icon-128.png b/icon-128.png new file mode 100644 index 0000000..998ce8c Binary files /dev/null and b/icon-128.png differ diff --git a/icon-16.png b/icon-16.png new file mode 100644 index 0000000..100573d Binary files /dev/null and b/icon-16.png differ diff --git a/icon-48.png b/icon-48.png new file mode 100644 index 0000000..1d545a3 Binary files /dev/null and b/icon-48.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..f3a1ee6 --- /dev/null +++ b/manifest.json @@ -0,0 +1,25 @@ +{ + "manifest_version": 2, + "name": "Mantis Helper", + "version": "1.0.0.0", + "permissions": ["contextMenus", "storage"], + "background": { + "scripts": ["background.js"] + }, + "description": "Select a number on a website and open it in Mantis from the context menu", + "options_ui": { + "page": "options.html", + "open_in_tab": true + }, + "icons": { + "16": "icon-16.png", + "48": "icon-48.png", + "128": "icon-128.png" + }, + "browser_specific_settings": { + "gecko": { + "id": "mantis-helper@example.com", + "strict_min_version": "57.0" + } + } +}