diff --git a/background/background.js b/background/background.js
index f50f220..cd982de 100644
--- a/background/background.js
+++ b/background/background.js
@@ -84,4 +84,26 @@ function saveWord (content) {
definitions
});
})
-}
\ No newline at end of file
+}
+
+browser.contextMenus.create({
+ id: "dictionary-anywhere-selection",
+ title: "Look up '%s' in Dictionary",
+ contexts: ["selection"]
+});
+
+browser.contextMenus.onClicked.addListener(function (info, tab) {
+ if (info.menuItemId === "dictionary-anywhere-selection") {
+ const code = `showMeaning({});`;
+
+ browser.tabs.executeScript({
+ code: "typeof showMeaning === 'function';",
+ }).then(() => {
+ return browser.tabs.executeScript(tab.id, {
+ code,
+ });
+ }).catch((error) => {
+ console.error("Failed to translate text: " + error);
+ });
+ }
+});
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index afb3465..601f0d9 100644
--- a/manifest.json
+++ b/manifest.json
@@ -40,6 +40,8 @@
"permissions": [
"storage",
+ "contextMenus",
+ "activeTab",
"https://www.google.com/"
]
}
diff --git a/options/options.html b/options/options.html
index d1ff023..d0c84b4 100644
--- a/options/options.html
+++ b/options/options.html
@@ -39,6 +39,7 @@
+