Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

277
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda