Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 用于自动填写由Angular创建的用户密码表单的内容脚本_Javascript_Jquery_Angularjs_Forms_Google Chrome Extension - Fatal编程技术网

Javascript 用于自动填写由Angular创建的用户密码表单的内容脚本

Javascript 用于自动填写由Angular创建的用户密码表单的内容脚本,javascript,jquery,angularjs,forms,google-chrome-extension,Javascript,Jquery,Angularjs,Forms,Google Chrome Extension,我已经创建了一个内容脚本扩展来自动填充网页上的用户和密码字段。它可以正常工作,如下所示- <input name="userId" class="form-field" id="userId" placeholder="Username" autocomplete="off" tabindex="1" type="text"> <input name="password" class="form-field" id="password" placeholder="Passwor

我已经创建了一个内容脚本扩展来自动填充网页上的用户和密码字段。它可以正常工作,如下所示-

<input name="userId" class="form-field" id="userId" placeholder="Username" autocomplete="off" tabindex="1" type="text">
<input name="password" class="form-field" id="password" placeholder="Password" autocomplete="off" tabindex="2" type="password">
<input name="signIn" class="btnBlue" id="signIn" value="Sign In" tabindex="4" onclick="checkIECompat()" type="button">

然而,当谈到角度生成的形式时,无论我多么努力地使用那些ng-xxxxxx类,它都不起作用

<input type="text" class="form-control text-center modal-header ng-valid-maxlength ng-touched ng-dirty ng-valid-parse ng-invalid ng-invalid-required" name="idCard" placeholder="User Name" maxlength="20" autocomplete="off" ng-model="request.userName" required="">
<input type="password" class="form-control text-center ng-dirty ng-valid-parse ng-touched ng-invalid ng-invalid-required" name="password" placeholder="Password" aria-describedby="" autocomplete="off" ng-model="request.password" style="margin-top:15px" required="">
<button type="submit" class="btn btn-blue btn_login" value="Log In" ng-click=" login('/payment')" ng-disabled="loginForm.$invalid" disabled="disabled">เข้าสู่ระบบ <span class="glyphicon glyphicon-log-in" style="font-size:14px" aria-hidden="true"></span></button>

เข้าสู่ระบบ 
上面是第一次加载页面时的代码。我手动输入表单,在检查所有有效性并启用提交按钮后检查代码。然后,我使用我的程序更改这些类和其他细节,使它们完全相同(除了顺序)。我甚至通过删除
disabled
属性来强制启用按钮,但它没有帮助。可以单击按钮,但不会发生任何事情

我的问题是“有可能做到这一点吗?”。关于Angular,是否有任何限制阻止内容脚本成功运行?或者,这只是编码问题,我一直无法使它工作


还有一个问题是我没有角度代码。它属于一个我想使用扩展名的网站。

按照@wOxxOm的指导,在设置输入值(更新角度模型)后添加以下行触发事件,我的问题就解决了

document.getElementsByName("idCard").item(0).value = 'XXXXX';
document.getElementsByName("idCard").item(0).dispatchEvent(new Event("input"));

在@wOxxOm的指导下,在设置输入值(更新角度模型)后,添加以下行以触发事件,我的问题就解决了

document.getElementsByName("idCard").item(0).value = 'XXXXX';
document.getElementsByName("idCard").item(0).dispatchEvent(new Event("input"));

正确处理敏感数据(用户名和密码)是一个难题,即使是拥有数十年计算机安全经验的人也会时不时地犯下危险的错误。一个令人严重关切的问题。对于任何一个人来说,这不是一个好主意。如果他们在安全地处理数据、使用扩展、使用网页等方面没有很长的经验,那么尤其如此。我建议你认真考虑其他项目。你是否发送了<代码>输入<代码>事件?可能是@Makyen:谢谢你的关心。我也考虑过这一点。因此,我的扩展将不会存储任何用户或密码。它只是在所需的页面上传递用户对表单的键。@wOxxOm:谢谢您指出这一点。是的,我的程序需要在设置值后触发该事件。现在可以了。我将在回答中更新我的代码。正确处理敏感数据(用户名和密码)是一个难题,即使是在计算机安全方面有几十年经验的人也会时不时地犯下危险的错误。一个令人严重关切的问题。对于任何一个人来说,这不是一个好主意。如果他们在安全地处理数据、使用扩展、使用网页等方面没有很长的经验,那么尤其如此。我建议你认真考虑其他项目。你是否发送了<代码>输入<代码>事件?可能是@Makyen:谢谢你的关心。我也考虑过这一点。因此,我的扩展将不会存储任何用户或密码。它只是在所需的页面上传递用户对表单的键。@wOxxOm:谢谢您指出这一点。是的,我的程序需要在设置值后触发该事件。现在可以了。我将在答案中更新我的代码。