Estoy desarrollando una extensión de Chrome que hace anotaciones para la palabra seleccionada, y quiero tomar todo el contexto para compararlo más tarde cuando busque la palabra.
Ejemplo:
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.por ahora, puedo almacenar y tomar la palabra seleccionada usando este código:
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) } })aqui esta la foto de la alerta
como seleccionar alerta de la palabra seleccionada
ahora quiero recuperar todo el párrafo o todo el contexto