Copy the links <a>

Hi,

I have created a FF web extension with context menus.

When I select a text and right click, I see my context menu, I click it and display the selected text. Here the selected text displayed is plain text where as I would like display the styles or links in the selected text.

How can I solve this please?

browser.contextMenus.onClicked.addListener(function (info, tab) {

	if (info.selectionText) {

		console.log(info.selectionText);

}

}

Any help is much appreciated

Thanks

Hmm, Firefox 56 added info.linkText. Maybe that will help? It’s not clear whether that is applicable to a selection or can be easily combined with it.

You may need to interrogate the selection using standard DOM methods.

info.linkText gives me the text of the link
and
info.selectedText gives me the plain text that is selected

But I would like to get the hyper links in the selected text
I was getting the below text “Sign in to your BBC account, or Register to see Weather, Local News and more”

Where as I would like to get actual html tags as below

Sign in to your BBC account, or Register to see Weather, Local News and more

You will have to get that information using a content script, listening for the contextmenu event and then getting the links inside the selection.