Chrome扩展程序使带有扩展名的鼠标单击 [英] Chrome extension making mouse click with extension
问题描述
是否可以通过调用另一个函数来使特定元素在单击时起作用?例如,我正在尝试制作一个扩展程序,一旦单击扩展程序,它将自动单击一个按钮.是否有可能实现这一目标,如果可以的话,有人可以指出我该怎么做的方向吗?
Is it possible to make particular elements act as it was clicked on them by calling another function? For example I am trying to make an extension which will automatically clicks a button once I click on the extension. Is it possible to achieve this and if so can somebody point me to the direction of how to do it?
推荐答案
我认为可以通过内容脚本来完成.我将在扩展名图标中添加一个侦听器,方法是在后台页面中单击.触发回调后,我将使用UI元素将内容脚本注入页面.在此内容脚本中,我会找到一个按钮并触发单击它.
I think this can be done by the content script. I would add a listener to the extension icon click in the background page. After the callback is triggered, I would inject a content script into the page with UI element. And in this content script I would find a button and trigger click on it.
这篇关于Chrome扩展程序使带有扩展名的鼠标单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!