Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
how to get context of the selected word chrome extension

I am developing a chrome extension that makes annotate for the selected word, and I want to take the whole context to compare it later when searching at the word.

Example:

A stack is a linear ***data structure*** that follows 
the LIFO (Last–In, First–Out) principle. 
That means the objects can be inserted or
 removed only at one end of it, also called a top.

for now, I can store and take the selected word using this code:

chrome.contextMenus.create(
    {
        "id": "annotate",
        "title": "Click To Add Comment 👆", /* what appears in the menu */
        "contexts": ['selection']  /* to make this appear only when user selects something on page */
    }
);


chrome.contextMenus.onClicked.addListener( (clickData) => {
    if(clickData.menuItemId == "annotate" && clickData.selectionText)
    {
        var selected = clickData.selectionText
        alert(selected)
    }
})

here is the picture of the alert

how to select alert of the selected word

now I want to retrieve the whole paragraph or the whole context

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!