Skip to content

Instantly share code, notes, and snippets.

@scottopell
Created March 2, 2016 01:43
Show Gist options
  • Save scottopell/c0889fe114fdf011a729 to your computer and use it in GitHub Desktop.
Save scottopell/c0889fe114fdf011a729 to your computer and use it in GitHub Desktop.
Who's Hiring Filter
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