Exact Find

From Chickenfoot Script Repository

 /**
  * Exact Find - exactfind(str)
  *    Strips tags from the body of the page, then search for string str.
  *    If there is a match, returns true. Otherwise, returns false.
  *
  * @author khamer
  * @date November 5, 2008
  */
 
 function strip_tags(str,allowed_tags){var key='',tag='',allowed=false;var matches=allowed_array=[];var allowed_keys={};var replacer=function(search,replace,str){return str.split(search).join(replace);};if(allowed_tags){allowed_array=allowed_tags.match(/([a-zA-Z]+)/gi);}
 str+='';matches=str.match(/(<\/?[^>]+>)/gi);for(key in matches){if(isNaN(key)){continue;}
 html=matches[key].toString();allowed=false;for(k in allowed_array){allowed_tag=allowed_array[k];i=-1;if(i!=0){i=html.toLowerCase().indexOf('<'+allowed_tag+'>');}
 if(i!=0){i=html.toLowerCase().indexOf('<'+allowed_tag+' ');}
 if(i!=0){i=html.toLowerCase().indexOf('</'+allowed_tag);}
 if(i==0){allowed=true;break;}}
 if(!allowed){str=replacer(html,"",str);}}
 return str;}
 function exactfind(str){content=strip_tags(document.body.innerHTML)
 return(content.indexOf(str)>-1);}