Why does setting autocomplete = "on" through a user script still prevent us from storing passwords in Chrome?

My goal is to use a Greasemonkey script style user in Google Chrome to enable password remembering in a specific form that has autocomplete="off" .

Chrome developer tools show that autocomplete="on" script is successfully installed, but this does not have the expected effect of allowing passwords to be stored on the form.

Why is this not working?


Example

Chrome suggests remembering the passwords entered on this test page (expected):

 <html><body><form action=""> <input type="text" name="username" /> <input type="password" name="password" /> <input type="submit" name="submit" value="Log In" /> </form></body></html> 

Chrome does not offer to remember passwords entered on this test page (expected):

 <html><body><form action=""> <input type="text" name="username" /> <input type="password" name="password" autocomplete="off" /> <input type="submit" name="submit" value="Log In" /> </form></body></html> 

The Chrome Inspect Element tool shows a successful modification of the above test page by a user script (expected):

 <html><head></head><body><form action="" autocomplete="on"> <input type="text" name="username" autocomplete="on"> <input type="password" name="password" autocomplete="on"> <input type="submit" name="submit" value="Log In"> </form></body></html> 

Chrome still doesn’t offer to remember passwords after this modification (Unexpectedly).

+4
source share
2 answers

As an experiment, try this bookmarklet, it will clear autocomplete and this dialog pops up (typical): Results dialog from bookmarklet

 javascript:(function%20(){var%20zCurrentElement=document.activeElement;var%20cfa,cea,cs,df,fe,i,j,sf,se;cfa=cea=cs=0;df=document.forms;for(i=0;i<df.length;i++){sf=df[i];fe=sf.elements;if(sf.onsubmit){sf.onsubmit='';cs++;}if(sf.attributes.autocomplete){sf.attributes.autocomplete.value='on';++cfa;}for(j=0;j<fe.length;j++){se=fe[j];if(se.attributes.autocomplete){se.attributes.autocomplete.value='on';cea++;}}}var%20zNode=document.createElement('div');zNode.setAttribute('id','idAPW_NotifWindow');zNode.innerHTML='<p>Removed:</p>'+'<ul>'+'<li>"autocomplete=off"%20from%20'+cfa+'%20form(s)<br>'+'%20and%20from%20'+cea+'%20form%20element(s).'+'<li>onsubmit%20from%20'+cs+'%20form(s).'+'</ul>'+'<p>After%20you%20type%20your%20password%20and%20submit%20the%20form,%20the%20browser%20will%20offer%20to%20remember%20your%20password.</p>'+'<style%20type="text/css">'+'#idAPW_NotifWindow'+'{'+'position:%20%20%20absolute;'+'visibility:%20visible;'+'margin:%205px;'+'padding:0em%202em%202em%202em;'+'max-width:%20%20400px;'+'background-color:%20%20%20orange;'+'border:%203px%20double;'+'font-size:%20%2014px;'+'text-align:%20left;'+'opacity:0.97;'+'z-index:1000;'+'cursor:%20pointer;'+'}'+''+'#idAPW_NotifWindow%20p,%20#idAPW_NotifWindow%20ul,%20#idAPW_NotifWindow%20li'+'{'+'margin:%200;'+'padding:%200;'+'line-height:130%;'+'}'+'#idAPW_NotifWindow%20p'+'{'+'padding:1em%200%200%200'+'}'+'#idAPW_NotifWindow%20ul'+'{'+'padding:0%200%200%202em;'+'}'+'#idAPW_NotifWindow%20li'+'{'+'margin:%200%200%200.5em%200;'+'}'+'</style>';zNode.style.top=window.scrollY+'px';zNode.style.left=window.scrollX+'px';document.body.appendChild(zNode);zNode.addEventListener("click",function(){var%20zNode=document.getElementById('idAPW_NotifWindow');if(zNode)zNode.style.visibility='hidden';},false);if(zCurrentElement){if(/input/i.test(zCurrentElement.tagName)){zCurrentElement.blur();zCurrentElement.focus();}}})(); 


If this works, then the GM script may be absent at the form level autocomplete="off" or there may be an onsubmit handler somewhere on the page.

If this does not work, this task may not be available in Chrome. (Note that a similar GM and bookmarklet work fine in Firefox. :))

+1
source

Autocomplete = on is one of the first extensions I installed. I recommend you read the source for it, as it contains some comments from an insider of Chromium. The problem is that Chrome checks all autocomplete attributes once at a specific time, so the script runs only when the DOM loads, but before Chrome checks for autocomplete.

There are a few new comments, although this indicates that the extension does not work in Chrome 9. Perhaps this deserves further study.

+1
source

Source: https://habr.com/ru/post/1338969/


All Articles