4

My goal is to use a Greasemonkey-style user script in Google Chrome to enable remembering of passwords on a specific form that has the autocomplete="off" attribute set.

Chrome's developer tools indicate that autocomplete="on" is being successfully set by the script, but this does not have the expected effect of allowing the storage of passwords on the form.

Why doesn't this work?


Example

Chrome offers to remember 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>

Chrome's Inspect Element tool reveals a successful modification of the above test page by the 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 does not offer to remember passwords after this modification (Unexpected).

1
  • Closed as TL at OP's request due to no further repro.
    – Kev
    Sep 3, 2012 at 22:11

2 Answers 2

1

As an experiment, try this bookmarklet, it clears autocompletes and pops up this dialog (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 that works, then the GM script may be missing a form-level autocomplete="off" or there may be an onsubmit handler somewhere in the page.

If it doesn't work, then this task is may not be possible in Chrome. (Note similar GM and the bookmarklet both work fine in Firefox. :) )

1

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

There are some new comments there though that indicate that the extension doesn't work in Chrome 9. Perhaps this merits further investigation.

Not the answer you're looking for? Browse other questions tagged or ask your own question.