var block = [ "Чужая2_3", "Макс Капризный", ]; var posts = document.getElementsByClassName("alt2"); for (var i = 0; i < posts.length; i++) { if(posts[i].querySelector("div > a > b") != null) { if(block.indexOf(posts[i].querySelector("div > a > b").innerText) != -1) { var el = posts[i].querySelector("div > a > b").parentNode.parentNode.parentNode.parentNode; el.style.visibility = "collapse"; } } }