Created
January 7, 2020 01:53
-
-
Save tomhodgins/f4d4f060c0df43629222230f1ad2d76d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.documentElement.textContent // Get all of the text content on the web page. | |
.replace(/\b(\s*\[at\]\s*)\b/g, '@') // Replace any ' [at] ' with '@'. | |
.split(/\s+/) // Split text content by whitespace between words. | |
.filter(Boolean) // Eliminate any empty words. | |
.filter(string => { // Filter list of words: | |
const input = document.createElement('input') // by creating an <input> element, | |
input.type = 'email' // setting the input type to email, | |
input.value = string.trim() // setting its value to the current word, | |
return input.checkValidity() // and checking if it's a valid email address. | |
}) // Result: a list of all valid emails on the page. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment