Skip to content

Instantly share code, notes, and snippets.

@AyrA

AyrA/search.js

Created Feb 18, 2018
Embed
What would you like to do?
Find and count multiple words on a website
(function (x) {
var text = document.body.textContent;
return x.map(function (v) {
var m = text.match(new RegExp("\\s(" + v + ")[\\s.,!?]", "gi"));
return m ? m.length : 0;
});
})(["add", "all", "your", "words", "here"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.