Skip to content

Instantly share code, notes, and snippets.

@kylejeske
Last active September 4, 2019 14:27
Show Gist options
  • Save kylejeske/e6dc589d76afbc8f916605931653e914 to your computer and use it in GitHub Desktop.
Save kylejeske/e6dc589d76afbc8f916605931653e914 to your computer and use it in GitHub Desktop.
Y 'Hackernews' - Filter List to only show remote positions
// https://news.ycombinator.com/item?id=20867123
// "Ask HN: Who is hiring? (September 2019)"
((context, skills=[]) => {
// findRemote, filter the list to only show remote positions
const findRemote = testText =>
testText.search(new RegExp(/remote/ig)) > -1
? true
: false;
const findSkills = skillText => skills => skillText.search(new RegExp(skills, 'ig')) > -1
? true
: false;
const findShowing = element => element.className.search(new RegExp(/noshow/), 'ig') > -1
? true
: false;
// filter by way of adding 'noshow' class
context
.filter(el =>
!findRemote(el.innerText)
)
.map(_ => _.setAttribute("class", "noshow"));
// filter out opportunities with provided skills
context
.filter(el => !findShowing(el)
&& !findSkills(el.innerText)(skills.join("|"))
)
.map(_ => _.setAttribute("class", "noshow"));
})($$(".commtext"), ["JS","javascript","Node","Node.JS"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment