get selected links in a page

Is there a way to get only the links from a page that are part of the current selection solely through script?

I figured out I can Create Note from the selection and then convert the new RTF document to HTML from which I can use script to get all of the links. So that kind of gets me close, but it involves some manual steps, which means it doesn’t work for me. But it seems that the functionality might be available internally but just not exposed through script. Is that the case or am I missing another way to achieve this?

(I also know that script can get the URL of selected rich text if the selection is one and only one link, but that case is too narrow for me also.)

Thanks a bunch.

Only if it’s a visible rich text:

tell application "DEVONthink Pro"
	set theLinks to {}
	tell text of think window 1
		repeat with theAttribute in attribute runs
			if exists URL of theAttribute then set theLinks to theLinks & URL of theAttribute
		end repeat
	end tell
	display dialog (theLinks as string)
end tell