Created
March 2, 2016 01:43
-
-
Save scottopell/c0889fe114fdf011a729 to your computer and use it in GitHub Desktop.
Who's Hiring Filter
This file contains 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
var keywords = ["NYC", "New York"]; | |
var els = document.getElementsByClassName("athing"); | |
[].forEach.call(els, function(ele){ | |
var regex = new RegExp("\\b" + keywords.join("|") + "\\b"); | |
var elementText = ele.innerHTML; // probably a few false positives, oh well. | |
if (regex.test(ele.innerHTML)){ | |
ele.style.display = "block"; | |
} else { | |
ele.style.display = "none"; | |
} | |
}); | |
// Oneliner | |
var keywords = ["NYC", "New York"]; var els = document.getElementsByClassName("athing"); [].forEach.call(els, function(ele){ if (new RegExp("\\b" + keywords.join("|") + "\\b").test(ele.innerHTML)){ ele.style.display = "block";} else { ele.style.display = "none"; } }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment