我发现了 Chrome 扩展 - 我现在的问题是,如何在扩展运行时单击按钮。例如,有一个 id='Submit' 的按钮。如何使用 chrome 扩展模拟单击此按钮。
例如,网页上有一个 id 为“Button1”的按钮 - 如何使用扩展程序自动单击。
示例:
<input id='submit' type='submit' name='submit'>
当我单击扩展程序时,我的扩展程序现在应该单击此按钮
感谢您的帮助:)
最佳答案
所以,我希望我理解正确。在 content_scripts->matches 下的 manifest.json 文件中,您需要设置您想要点击他的按钮的网络地址,例如,如果您想在 Gmail 页面中显示他的所有路由:
"content_scripts": [
{
"matches": ["http://mail.google.com/*", "https://mail.google.com/*"],
"js": ["content.js"],
"run_at": "document_end"
}
]
(/* 意味着在 gmail 中的任何路由中此脚本都可用)
然后在您的 content.js 页面中,您需要获取/创建按钮并模拟点击他:
document.getElementById("buttonSample").click();
祝你好运!
关于javascript - Chrome 扩展 - 在页面上执行某些操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42786392/