-- by using apple script -> u converted this into java script
eg : set mydoc to active document -> apple script
var myDoc = app.activeDocument -> java script
select text of selection
set SourceText to item 1 of selection as string
set hrperlnk to hyperlinks
set LnkTxt to 0
set HyperLnkTxt to hyperlink text sources
repeat with i from 1 to count of HyperLnkTxt
set HyperLnkSrc to item i of HyperLnkTxt
set src to contents of source text of HyperLnkSrc
if src is equal to SourceText then
set LnkTxt to 1
set HyperLnkSrc to item i of HyperLnkTxt
exit repeat
end if
end repeat