从具有chrome扩展名的chrome自动填充中读取值

问题描述 投票:0回答:1

我正在尝试做的事情:

开发一个chrome扩展程序,该扩展程序在网站上提交表单(通过按钮单击事件)。表单的输入字段由chrome自动填充功能填充。为此,可以使用内容脚本的声明式js注入。该表格如下所示:

           <form action="...." method="post">
                <table style="margin-top:4px; margin-bottom:4px">
                    <tr>
                        <td width="40%">
                            <label for="username">Login:</label>
                        </td>
                        <td>
                            <input name="i_username" type="text" id="username" autocapitalize="off" value="" autofocus/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="password">Passwort:</label>
                        </td>
                        <td>
                            <input name="i_password" type="password" id="password"/>
                        </td>
                    </tr>

                    <tr>

                        <td>
                            <button type="submit" name="proceed" value="Login">Login</button>
                        </td>
                    </tr>
                </table>
            </form>

会发生什么:

页面已加载。这些值由chrome自动填充功能填充,人眼可见。但是,当我尝试使用javascript读取输入值时,它们为空。 (因此,使用按钮提交表单会出错,因为值是“空”。)实际用户与页面互动后,就可以在我的JavaScript中访问这些值。

我对此主题进行了大量研究,包括以下内容:

我尝试了各种解决方案来模拟“真实的用户交互”以及其他变通方法。我试图用js键事件或鼠标事件模拟真实的用户输入。我还尝试触发.blur()、. focus()...。

之类的事件。

是否有可能以任何方式完全无需用户交互而读取自动填充的值?

实际上,获取值就足够了,这些值由chrome自动填充填充。例如,最好直接从chrome密码存储中读取它们(我知道这是不可能的)。

谢谢,OliDev

[我正在尝试做的事情:开发一个chrome扩展程序,该扩展程序在网站上提交表单(通过按钮单击事件)。表单的输入字段由chrome自动填充功能填充。为此,请使用声明式...

javascript html google-chrome-extension autofill content-script
1个回答
0
投票

我要回答我自己的问题:

© www.soinside.com 2019 - 2024. All rights reserved.