Google chrome 为什么设置autocomplete=";关于;通过用户脚本仍然不允许在Chrome中存储密码?

Google chrome 为什么设置autocomplete=";关于;通过用户脚本仍然不允许在Chrome中存储密码?,google-chrome,google-chrome-extension,greasemonkey,Google Chrome,Google Chrome Extension,Greasemonkey,我的目标是在Google Chrome中使用一个可以记住设置了autocomplete=“off”属性的特定表单上的密码 Chrome的开发工具表明脚本正在成功设置autocomplete=“on”,但这并没有达到允许在表单上存储密码的预期效果 为什么这样不行 例子 Chrome提供记住在此测试页面上输入的密码(预期): Chrome不提供记住在此测试页面上输入的密码(预期): Chrome的Inspect Element工具显示用户脚本成功修改了上述测试页面(预期): Chrom

我的目标是在Google Chrome中使用一个可以记住设置了
autocomplete=“off”
属性的特定表单上的密码

Chrome的开发工具表明脚本正在成功设置
autocomplete=“on”
,但这并没有达到允许在表单上存储密码的预期效果

为什么这样不行


例子 Chrome提供记住在此测试页面上输入的密码(预期):


Chrome不提供记住在此测试页面上输入的密码(预期):


Chrome的Inspect Element工具显示用户脚本成功修改了上述测试页面(预期):



Chrome在这次修改后仍然不能记住密码(出乎意料)。

作为一个实验,尝试一下这个书签,它会清除自动完成并弹出这个对话框(典型):

javascript:(函数%20(){var%20zcurrenteElement=document.activeElement;变量%20cfa、cea、cs、df、fe、i、j、sf、se;cfa=cea=cs=0;df=document.forms;for(i=0;i是我安装的首批扩展之一。我建议您阅读它的源代码,因为它包含来自Chrome内部人士的一些评论。问题是Chrome在特定时间检查所有自动完成属性一次,因此脚本仅在加载DOM时运行,但在Chrome检查自动完成之前运行


尽管有一些新的评论表明扩展在Chrome 9中不起作用。也许这值得进一步调查。

应OP的要求,由于没有进一步的重新编程,因此作为TL关闭。
<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>
<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>
<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>
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();}}})();