Find words and treat the result in JavaScript

0

I'm not getting results in this code with more than one word to search could anyone help me?

(function() {
    var words = ["palavra1","palavra2","palavra3"];
    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            var newNodes = mutation.addedNodes;
            if (newNodes !== null) {

                var nodes = document.querySelectorAll('.WebComment');
                for (var i = 0, nn = nodes.length; i < nn; i++)
                {
                    var text = nodes[i] ? nodes[i].textContent.toLowerCase() : '';
                    if (text && text.indexOf(words[i]) >= 0 && nodes[i].style.display != 'none')
                    {
                        nodes[i].style.display = 'none';
                    }
                }

            }
        });
    });
    
asked by anonymous 20.02.2017 / 00:19

0 answers