// ==UserScript==
// @name           Autocomplete Finder
// @namespace      http://www.mindedsecurity.com
// @description    Displays a bottom border for any input box coloring it green if autocomplete is off and red if it is set to on.
// @include        *
// @version        1.0
// @author         stefano.dipaola@mindedsecurity.com
// ==/UserScript==

document.addEventListener('DOMAttrModified', function (event)
{
  // console.dir(event)
    if (event.attrName=="autocomplete"){
      if(event.newValue.toLowerCase()=="off"  ){
           
         if( event.target.style) {event.target.style.borderBottom='';
             event.target.style.cssText += 'border-bottom: 3pt solid green !important';
            
         }      
      }else{
           if( event.target.style) {
                  event.target.style.borderBottom='';
                   event.target.style.cssText += 'border-bottom: 3pt solid red !important';
                   
          } 
          f();
      }
    }
}, false);

document.addEventListener ('DOMNodeInserted',function (event)
{
   if(event.target.querySelectorAll)
     for(var i in x=event.target.querySelectorAll('input')) {
     try{
          if(x[i].type!="text")
             continue;
              if((x[i].getAttribute("autocomplete") && x[i].getAttribute("autocomplete")=="off" ) ||(x[i].form && x[i].form.getAttribute("autocomplete")=="off")) {
                //x[i].previousSibling.textContent+=" AC=off "; 
 
                if(x[i].style){
                   x[i].style.borderBottom='';
                   x[i].style.cssText += 'border-bottom: 3pt solid green !important';
                }
              //  x[i].title+='|'+x[i].name
              }else{
                if(x[i].style){
                  x[i].style.borderBottom='';
                  x[i].style.cssText += 'border-bottom: 3pt solid red !important';
                  }
                //x[i].previousSibling.textContent+=" AC=on ";
                x[i].title+='|'+x[i].name
                //console.dir(x[i]);
              }
        }catch(e){  console.log(e)}
    } 
}
 , false);
function f(){
    for(var i in x=document.querySelectorAll('input')) {
     try{
          if(x[i].type!="text")
             continue;
              if((x[i].getAttribute("autocomplete") && x[i].getAttribute("autocomplete")=="off" ) ||(x[i].form && x[i].form.getAttribute("autocomplete")=="off")) {
                //x[i].previousSibling.textContent+=" AC=off "; 
 
                if(x[i].style){
                   x[i].style.borderBottom='';
                   x[i].style.cssText += 'border-bottom: 3pt solid green !important';
                }
              //  x[i].title+='|'+x[i].name
              }else{
                if(x[i].style){
                  x[i].style.borderBottom='';
                  x[i].style.cssText += 'border-bottom: 3pt solid red !important';
                  }
                //x[i].previousSibling.textContent+=" AC=on ";
                x[i].title+='|'+x[i].name
                //console.dir(x[i]);
              }
        }catch(e){  console.log(e)}
    }
   
}
window.addEventListener("load", f , false);

