The problem is that when I combine two functions that are:
- Retrieves all website HTML tag identifiers.
- looking for an array for "Bad Words" (AKA. "Hack", "Hacker", etc.).
Code 1:
var eleng=document.documentElement.getElementsByTagName('*').length -1; var i=0; var id=[]; function allids() { if (i < eleng) { id.push(document.documentElement.getElementsByTagName('*')[i].id); if (id[i] == '' || id[i] == ' ') { i++; allids(); } else { console.log(id[i]); i++; allids(); } } else { console.log("\nDone!"); } }
Code 2:
var str="HELLO"; var words=['hello','hack','hacker']; var i=0; function check() { if (str.indexOf(words[i]) > -1 || str.indexOf(words[i].charAt(0).toUpperCase()) > -1 || str.indexOf(words[i].toUpperCase()) > -1) { console.log('Word Found!'); } else { if (i < words.length) { i++; check(); } } }
Of course, code 2 would be in a new function already tried, but without success :( and it will be edited to the needs of code 1, I just could not worry about re-writing the script to satisfy I like Save As, but let me know if it is inconvenient.
PS I use Javascript VANILLA, so that means there are no fancy things like jQuery!
source share