From cd325fceaf5beb27f0f5cca52d8ea2ec05be1c2a Mon Sep 17 00:00:00 2001 From: Giteadmin Date: Fri, 8 Sep 2023 22:16:24 +0200 Subject: [PATCH] Upload files to "/" --- background.js | 19 +++++++++++++++++++ manifest.json | 10 ++++++++++ 2 files changed, 29 insertions(+) create mode 100644 background.js create mode 100644 manifest.json diff --git a/background.js b/background.js new file mode 100644 index 0000000..6dea0da --- /dev/null +++ b/background.js @@ -0,0 +1,19 @@ +chrome.runtime.onInstalled.addListener(() => { + chrome.contextMenus.create({ + id: 'openInMantis', + title: 'Open in Mantis', + contexts: ['selection'] + }); +}); + +chrome.contextMenus.onClicked.addListener((info) => { + if (info.menuItemId === 'openInMantis') { + let selectedText = info.selectionText; + if (selectedText.startsWith('#')) { + selectedText = selectedText.substring(1); + } + const fixedUrl = 'https://ot.syncore.at/view.php?id='; + const completeUrl = `${fixedUrl}${selectedText}`; + chrome.tabs.create({ url: completeUrl }); + } +}); diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..2740094 --- /dev/null +++ b/manifest.json @@ -0,0 +1,10 @@ +{ + "manifest_version": 3, + "name": "Open in Mantis", + "version": "1.0", + "permissions": ["contextMenus"], + "background": { + "service_worker": "background.js" + }, + "description": "Open selected number in Mantis" +}