Html 停止 LastPass 填写表格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20954944/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:21:47  来源:igfitidea点击:

Stop LastPass filling out a form

htmlformslastpass

提问by Marco

Is there a way to prevent the LastPass browser extension from filling out a HTML-based form with a input field with the name "username"?

有没有办法阻止 LastPass 浏览器扩展填写带有名称为“用户名”的输入字段的基于 HTML 的表单?

This is an hidden field, so I don't want any software to use this field for their purposes:

这是一个隐藏字段,所以我不希望任何软件将这个字段用于他们的目的:

<input type="text" name="username" id="checkusername" maxlength="9" value="1999" class="longinput" style="display:none">

The solution should not be like "rename the input field".

解决方案不应该像“重命名输入字段”。

回答by whatismybrowser.com

Adding

添加

data-lpignore="true"

to an input field disabled the grey LastPass [...] box for me.

到输入字段为我禁用了灰色的 LastPass [...] 框。

Sourced from LastPass.com

来自LastPass.com

回答by takeshin

Two conditions have to be met:

必须满足两个条件:

  1. The form(not the element) needs to have autocomplete="off"attribute
  2. Lastpass user needs to have this option enabled: Settings > Advanced > Allow pages to disable autofill
  1. 形式(未在元件)需要具有autocomplete="off"属性
  2. Lastpass 用户需要启用此选项: Settings > Advanced > Allow pages to disable autofill

So this depends on both user and the developer.

所以这取决于用户和开发者。

回答by Alexander Gorbatenko

What worked for me is having word "-search-" in the id of the form, something like <form id="affiliate-search-form">- and lastpass doesn't add its elements onto the form inputs. It works with something simpler like <form id="search">but doesn't work with <form id="se1rch">

对我有用的是在表单的 id 中有“-search-”这个词,就像<form id="affiliate-search-form">- 而 lastpass 不会将其元素添加到表单输入中。它适用于更简单的东西,<form id="search">但不适用于<form id="se1rch">

回答by jan

I know I'm late to the party here, but I found this when I was trying to stop lastpass from ruining my forms. @takeshin is correct in that autocomplete is not enough. I ended up doing the hack below just to hide the symbol. Not pretty, but I got rid of the icon.

我知道我在这里参加聚会迟到了,但是当我试图阻止 lastpass 破坏我的表格时,我发现了这一点。@takeshin 是正确的,因为自动完成是不够的。我最终做了下面的 hack 只是为了隐藏符号。不漂亮,但我摆脱了图标。

If any lastpass developers are reading this, please give us an attribute to use, so we don't have to resort to stuff like this.

如果任何 lastpass 开发人员正在阅读本文,请给我们一个要使用的属性,这样我们就不必求助于这样的东西。

form[autocomplete="off"] input[type="text"] {
    background-position: 150% 50% !important;
}

回答by mituw16

I thinklastpass honors the autocomplete="off"attribute for inputs, but I'm not 100% sure.

认为lastpass 尊重autocomplete="off"输入的属性,但我不是 100% 确定。

EDITAs others have pointed out. this only works if the user has last pass configured to honor this.

编辑正如其他人指出的那样。这仅在用户将最后一次通过配置为兑现这一点时才有效。

回答by MushyPeas

For me worked either type=searchwhich is kinda equal to textor using role=note.

对我来说,type=search这有点等于text或使用role=note.

You can check the LastPass-JavaScript but it's huge, may be you can find some workaround there, from what I saw they only check 4 input types, so input type=searchwould be one workaround:

您可以检查 LastPass-JavaScript 但它很大,也许您可​​以在那里找到一些解决方法,据我所知,他们只检查 4 种输入类型,因此input type=search是一种解决方法:

!c.form && ("text" == c.type || "password" == c.type || "url" == c.type || "email" == c.type) && lpIsVisible(c))

Also those are the role-keywords they seem to ignore:

这些也是role他们似乎忽略的-keywords:

var c = b.getAttribute("role");
switch (c) {
case "navigation":
case "banner":
case "contentinfo":
case "note":
case "search":
case "seealso":
case "columnheader":
case "presentation":
case "toolbar":
case "directory":`

I checked LastPass' onloadwff.js, prepare for 26.960 lines of code :)

我检查了 LastPass' onloadwff.js,准备 26.960 行代码:)

回答by Alex

Add "search" to input id

将“搜索”添加到输入 id

<input type="text" name="user" id="user-search"/>

回答by PeteAUK

Bit late to the party but I have just achieved this with modifying the form with:

聚会有点晚了,但我刚刚通过修改表单实现了这一点:

<form autocomplete="off" name="lastpass-disable-search">

I guess this fools lastpass into thinking that it's a search form. This does not work for password fields however! Lastpass ignores the name field in this case.

我猜这个傻瓜最后认为它是一个搜索表单。但是,这不适用于密码字段!在这种情况下,Lastpass 会忽略名称字段。

The only way I've managed to do this is to add the following directly at the top of the form:

我设法做到这一点的唯一方法是直接在表单顶部添加以下内容:

<form autocomplete="off">
    <div id="lp" ><input type="text" /><input type="password" /></div><script type="text/javascript">setTimeout(function(){document.getElementById('lp').style.display = 'none'},75);</script>
</form>

It causes a nasty flicker but does remove the autofill nonsense - though it does still show the "generate password" widget. LastPass waits until domready and then checks to see if there are any visible password fields, so it's not possible to hide or shrink the mock fields above.

它会导致令人讨厌的闪烁,但确实删除了自动填充的废话 - 尽管它仍然显示“生成密码”小部件。LastPass 等待直到 domready 然后检查是否有任何可见的密码字段,因此不可能隐藏或缩小上面的模拟字段。

回答by ccalvert

This ES6 style code was helpful for me as it added data-lpignoreto all my input controls:

这个 ES6 风格的代码对我很有帮助,因为它向我所有的输入控件添加了data-lpignore

const elements = document.getElementsByTagName("INPUT");
for (let element of elements) {
    element.setAttribute("data-lpignore", "true");
}

To access a specific INPUT control, one could write something like this:

要访问特定的 INPUT 控件,可以编写如下内容:

document.getElementById('userInput').setAttribute("data-lpignore", "true");

Or, you can do it by class name:

或者,您可以按类名进行操作:

const elements = document.getElementsByClassName('no-last-pass');
for (let element of elements) {
    element.setAttribute("data-lpignore", "true");
}

回答by Tony Brasunas

For this latest October 2019 buggy release of Lastpass, this simple fix seems to be best.

对于 2019 年 10 月最新版的 Lastpass,这个简单的修复似乎是最好的。

Add

添加

type="search"

type="search"

to your input.

到您的输入。

The lastpass routine checks the typeattribute to determine what to do with its autofill, and it does nothing on this html5 typeof "search." Sure this is mildly hacky, but it's a one line change that can be easily removed when they fix their buggy script.

lastpass 例程检查type属性以确定如何处理它的自动填充,并且它对这个type“搜索”的html5 不做任何事情。当然,这有点老套,但这是一个单行更改,可以在他们修复有缺陷的脚本时轻松删除。

Note that after doing this, your input might appear to be styled differently by some browsers if they pick up on the typeattribute. If you observe this, you can prevent it from happening by setting the browser-specific CSS properties -webkit-appearanceand -moz-appearanceto 'none'on your input.

请注意,执行此操作后,如果某些浏览器选择该type属性,则您的输入可能会显示为不同的样式。如果您观察到这一点,您可以通过在您的输入中设置特定于浏览器的 CSS 属性-webkit-appearance-moz-appearanceto来防止它发生'none'