Answers for "get all visible text on website javascript"

0

get all visible text on website javascript

function isHidden(el) {
     var style = window.getComputedStyle(el);
     return ((style.display === 'none') || (style.visibility === 'hidden'))
 }

 // get the body tag
 var body = document.querySelector('body');

 // get all tags inside body
 var allTags = body.getElementsByTagName('*');


 //console.log(allTags);


 for (var i = 0, max = allTags.length; i < max; i++) {
     if (isHidden(allTags[i])){
         // hidden
     }
     else { 
         console.log(allTags[i].innerText);
     }
 }
Posted by: Guest on April-09-2021

Code answers related to "get all visible text on website javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language