javascript - 我在使 istrusted 事件为 true 以单击网页时遇到问题。我正在使用 chrome 扩展程序单击
问题描述
我面临着使点击事件在 chrome 扩展中受信任的问题。我已经看到了一个堆栈溢出答案,它描述了我们可以在 chrome.debugger.attach 的帮助下完成,但是我不确定如何将它包含到我的代码中。抱歉,我对扩展很陌生,我已经编写了 js 代码来单击按钮,但是它发送istrusted=false
.
我有一个清单文件,一个alert.js
文件和一个code.js
包含单击按钮的代码的文件。
这是我在 StackOverflow 上看到的代码,但我无法实现它:
chrome.debugger.attach(target, "1.2", function()
{
chrome.debugger.sendCommand(target, "Input.dispatchMouseEvent", arguments)
})
我的 alert.js 文件
injectScript( chrome.extension.getURL('code.js'), 'body');
function injectScript(file, node)
{
var th = document.getElementsByTagName(node)[0];
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', file);
th.appendChild(s);
}
我的 code.js 文件是一个小代码,用于单击我需要发送可信事件的按钮。
我只需要发送istrusted
到 true ,因为许多网站可以跟踪用户正在使用它点击脚本。
解决方案
推荐阅读
- c++ - 使用 C++ 用户定义的文字来初始化数组
- slack - 如何使用动态消息选项向 Slack 发送响应
- ios - SWIFT 使用 Stringsdict 和复数规则
- javascript - 当本机反应发生此错误时:transformClassesWithDexBuilderForDebug?
- python - 在 iPython 笔记本中使用 graphlab.SFrame 时出现许可证错误,即使我使用的是有效的许可证密钥
- swift - Alamofire 使用数据设置请求正文
- apache-flink - 在 Yarn 中运行 Flink
- android - Android 9 Pie 在手机上创建 SQLite 数据库文件的变化(?)
- android - err_unknown_url_scheme WebView
- node.js - newman CLI 在 teamcity 构建中返回“错误:无法获取本地颁发者证书”