Skip to content

Instantly share code, notes, and snippets.

@ruslankonev
Last active August 29, 2015 14:02
Show Gist options
  • Save ruslankonev/dfb2d401b7b08de40eef to your computer and use it in GitHub Desktop.
Save ruslankonev/dfb2d401b7b08de40eef to your computer and use it in GitHub Desktop.
Find and unique all emails in page (javascript)
var body = window.document.body.innerHTML;
//var body = document.querySelector('td.Bu').innerHTML
var regular = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/ig;
var arrayUnique = function(a) {
return a.reduce(function(p, c) {
if (p.indexOf(c) < 0) p.push(c);
return p;
}, []);
};
arrayUnique(body.match(regular));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment