showing results for - "get all visible text on website javascript"
Silvia
06 Jun 2017
1 function isHidden(el) {
2     var style = window.getComputedStyle(el);
3     return ((style.display === 'none') || (style.visibility === 'hidden'))
4 }
5
6 // get the body tag
7 var body = document.querySelector('body');
8
9 // get all tags inside body
10 var allTags = body.getElementsByTagName('*');
11
12
13 //console.log(allTags);
14
15
16 for (var i = 0, max = allTags.length; i < max; i++) {
17     if (isHidden(allTags[i])){
18         // hidden
19     }
20     else { 
21         console.log(allTags[i].innerText);
22     }
23 }
24