gpt4 book ai didi

javascript - 以编程方式为 Facebook 搜索输入赋予值(value),以便它返回建议框

转载 作者:行者123 更新时间:2023-12-03 03:49:48 24 4
gpt4 key购买 nike

我试图以编程方式为 Facebook 搜索提供一个值,它会刷新并打开建议框,就像用户输入该值一样。

<div class="wrap">
<input type="hidden" autocomplete="off" class="hiddenInput" value="hello">
<div class="innerWrap">
<div class="_5861 navigationFocus textInput _5eaz" id="u_r_2">
<input type="text" class="_5eay" disabled="1" aria-hidden="1" value="XXXX">
<input type="text" class="_1frb" name="q" value="hello" autocomplete="off" placeholder="Search Facebook" data-testid="search_input" role="combobox" aria-label="Search" aria-autocomplete="list" aria-expanded="false" aria-controls="typeahead_list_u_r_1" aria-activedescendant="js_ail"></div>
</div>
</div>

我尝试使用 $0.setAttribute('value', 'hello') 在控制台中设置值,但它不会启动建议过程。

有办法实现吗?

最佳答案

尝试执行execCommand。它会为您调用事件。

https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand

首先关注输入框

$0.focus()

然后使用execCommand insertText

document.execCommand('insertText', undefined, "Hello")

唯一的问题是,结果仅在下拉菜单已打开时显示。我建议也弄清楚如何触发它。

关于javascript - 以编程方式为 Facebook 搜索输入赋予值(value),以便它返回建议框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45216227/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com