On 7/23/11 1:43 PM, Stanimir Stamenkov wrote:
> Sun, 17 Jul 2011 21:11:48 +0300, /Stanimir Stamenkov/:
> 
>> Here's already revised code to handle forms found in frames,
>> additionally:
>>
>> let lm = Components.classes["@mozilla.org/login-manager;1"]
>>          .getService(Components.interfaces.nsILoginManager);
>>
>> function fillForms(doc) {
>>   let forms = doc.forms;
>>   for (let i = 0; i < forms.length; i++) {
>>     lm.fillForm(forms[i]);
>>   }
>> }
>>
>> fillForms(content.document);
>>
>> let frames = content.frames;
>> for (let i = 0; i < frames.length; i++) {
>>   fillForms(frames[i].document);
>> }
> 
> Here's the code for a complimentary button which will allow saving 
> the passwords on pages which normally suppress it.  I've generally 
> taken the code of the "remember password" [1] bookmarklet and 
> enhanced it to traverse into frames:
> 
> let ca, cea, cs;
> ca = cea = cs = 0;
> 
> function rememberPasswords(document) {
>    let documentForms = document.forms;
>    for (let i = 0; i < documentForms.length; i++) {
>      let form = documentForms[i];
>      let formElements = form.elements;
>      if (form.hasAttribute("onsubmit")) {
>        form.onsubmit = "";
>        cs++;
>      }
>      if (form.attributes["autocomplete"]) {
>        form.attributes["autocomplete"].value = "on";
>        ca++;
>      }
>      for (let j = 0; j < formElements.length; j++) {
>        let element = formElements[j];
>        if (element.attributes["autocomplete"]) {
>          element.attributes["autocomplete"].value = "on";
>          cea++;
>        }
>      }
>    }
> }
> 
> rememberPasswords(content.document);
> 
> let frames = content.frames;
> for (let i = 0; i < frames.length; i++) {
>    rememberPasswords(frames[i].document);
> }
> 
> function n(i, what) {
>    return i + " " + what + ((i == 1) ? "" : "s")
> }
> alert("Removed autocomplete=off from " + n(ca, "form")
>        + " and from " + n(cea, "form element")
>        + ", and removed onsubmit from " + n(cs, "form")
>        + ". After you type your password and submit the form,"
>        + " the browser will offer to remember your password.");
> 
> Having this in a chrome button rather than as a bookmarklet should 
> make it work in more cases where the password forms are found in 
> frames with a different than the embedding document origin.  This 
> should generally make the "nsLoginManager.js" hacks suggested 
> elsewhere, unnecessary.
> 
> [1] https://www.squarefree.com/bookmarklets/forms.html#remember_password
> 

The simple tweak in nsLoginManager.js that worked in SM 2.0.x no longer
works in SM 2.1 or 2.2 even if I unzip omni.jar to get at
nsLoginManager.js and then rezip after doing the tweak.  This was
described at <http://cybernetnews.com/firefox-remember-passwords/> and
avoided the need for a bookmarklet or button.

Could you possibly come up with an effective tweak to replace it, one
that still avoids the need for user action at the time of login?

-- 

David E. Ross
<http://www.rossde.com/>

On occasion, I might filter and ignore all newsgroup messages
posted through GoogleGroups via Google's G2/1.0 user agent
because of spam from that source.
_______________________________________________
support-seamonkey mailing list
support-seamonkey@lists.mozilla.org
https://lists.mozilla.org/listinfo/support-seamonkey

Reply via email to