I am working on a chrome extension. What i want to accomplish is, when i open a received email, the url from the email text should be detected and an alert box should show which url has been returned from the text. What I have done so far is :
function urlify(text) {
var urlRegex = /(https?:\/\/[^\s]+)/g;
return text.replace(urlRegex, function(url) {
return url;
})
}
var text = document.getElementsByClassName("adn ads")[0].innerText;
var html = urlify(text);
This code detects the URL but, also the returns the rest of the text with it. I just want this function to return me that specified detected url.
document.getElementsByClassName("adn ads")[0].innerText;wit an actual example so your snippet could run?