# How to modify / add to context menu within selection?

**URL:** <https://discourse.mozilla.org/t/how-to-modify-add-to-context-menu-within-selection/93019>\
**Category:** Development\
**Created:** [February 13, 2022, 2:05pm UTC](https://discourse.mozilla.org/t/how-to-modify-add-to-context-menu-within-selection/93019 "2022-02-13T14:05:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alabamatoy](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@alabamatoy](https://discourse.mozilla.org/u/alabamatoy)\
**Post date:** [February 13, 2022, 2:05pm UTC](https://discourse.mozilla.org/t/how-to-modify-add-to-context-menu-within-selection/93019/1 "2022-02-13T14:05:49Z")

</div>

I would like to have a special URL in my FF context menu so that when I select some text and right click on it, I can have an option to add that text into a specific URL, as in [https://somesite.com/?MySelectedText](https://somesite.com/?MySelectedText) and go to that URL… but I cannot seem to figure out how to do this. Is this possible?

---

<div class="post-metadata">

**Author:** ![hans\_squared](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/hans_squared/32/67424_2.png) [@hans\_squared](https://discourse.mozilla.org/u/hans_squared)\
**Post date:** [February 13, 2022, 4:12pm UTC](https://discourse.mozilla.org/t/how-to-modify-add-to-context-menu-within-selection/93019/2 "2022-02-13T16:12:16Z")

</div>

Yes, it is possible. Take a look at LEO Dictionaries to see how it’s done…

> **[LEO Dictionaries – Get this Extension for 🦊 Firefox (en-US)](https://addons.mozilla.org/en-US/firefox/addon/leo-dictionaries/)**
>
> Download LEO Dictionaries for Firefox. This is the official add-on for easier access to LEOs Online Dictionaries. Select any word or phrase, right-click on the selection and translate from/to English, French, Spanish, Italian, Chinese, Russian,...

---

<div class="post-metadata">

**Author:** ![ComputerWhiz](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/computerwhiz/32/20011_2.png) [@ComputerWhiz](https://discourse.mozilla.org/u/ComputerWhiz)\
**Post date:** [February 14, 2022, 1:52pm UTC](https://discourse.mozilla.org/t/how-to-modify-add-to-context-menu-within-selection/93019/3 "2022-02-14T13:52:44Z")

</div>

Yeah, you can do it using the window.getSelection() function from a content script. I’ve done something similar in [my add-on](https://github.com/WesleyBranton/Outlook.com-mailto). I did some messaging to the background script, but I don’t think that’s necessary. To be honest, it’s been so long, I can’t remember off the top of my head why I did it that way anyway.
