RoboForm 或 AutoFill 如何识别 iframe 中的文本框

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

我正在尝试复制 RoboForm 的基本版本 https://help.roboform.com/hc/en-us/articles/360042538712-How-to-use-AutoSave-and-Inplace-AutoFill)或自动填充 https://chrome.google.com/webstore/detail/autofill/nlmmgnhgdeffjkdckmikfpnddkbbfkkk?hl=en)chrome 扩展,我想在这里填写表格(https://stripe.com/jobs/listing/account-执行-baas/4954092/申请)。主要问题是条带表单使用 iframe 来呈现文本框。因此,我无法主动获取和设置文本框的值,除非我进行手动检查来渲染 iframe,从而为我提供 iframe 文本框 id。 RoboForm 和 AutoFill 似乎可以访问文本框的 id 值,而无需在此处执行任何独特的操作。请参阅随附的屏幕截图 (Screenshot of AutoFill Filling Form),其中显示了 Roboform 如何获取文本框的 id,以便能够将其图标覆盖在文本上,并且在我在 Chrome 上打开链接后立即自动填充填充视图,而无需重新加载 iframe或检查 iframe 上的任何元素

我尝试使用所有基本方法来查询 iframe,

document.querySelectorAll('input, iframe'); // to get the iframe id I want 
document.getElementById('grnhse_iframe'); // get the iframe element 
document.getElementById('grnhse_iframe').contentWindow.document; // to get iframe document but I had the error 

198:1 Uncaught DOMException: Blocked a frame with origin "https://stripe.com" from accessing a cross-origin frame.at <anonymous>:1:55

我知道此错误消息是由于同源策略引起的,这是一种安全措施,可防止网页向不同的域发出请求或从不同的域访问框架的内容。

作为解决方法,我使用 XAMPP 和 PHP 创建一个代理服务器,其中包含以下代码

<?php $url = $_GET['url']; $response = file_get_contents($url); echo $response; ?>
和 尝试将 iframe 的 src 设置为
http://localhost/iframe_proxy/index.php?${targetUrl}
其中 targetUrl 是我从 document.getElementById('grnhse_iframe') 获得的 iframe 中的 src。设置 URL 不断给我 [仅限报告]拒绝陷害……” Screenshot of Error when i try to set the URL

我怀疑 RoboForm 和 AutoFill 正在对我不知道的 iframe 进行不同的渲染,并且非常感谢这里的任何帮助。既然他们能够做到这一点,我相信应该有一种方法让我能够获取文本框并填充它,而无需手动检查元素。

javascript html google-chrome iframe artificial-intelligence
1个回答
0
投票

如果有人阅读了上述内容并正在寻求建议,在我看来,如果您正在编写自动登录脚本,这只是一个建议,但作为长期的 roboform 用户,roboform 似乎能够读取和保存表单在具有 iframe 的页面上没有问题的详细信息,我认为它的填充可能链接到 roboform 试图填充的 url。假设您的 iframe 页面是 index.php,它会将 info_form.php 调用到 iframe 中。 roboform 有两个 url,保存一个 goto url 和一个匹配 url,对于 iframe,这将是两个不同的 url,导致 roboform 拒绝表单填写,因为不匹配,我为我的一个 iframe 表单创建了一个登录作为示例。所以你的代码必须检查并可能找到一种匹配两者的方法。

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