【问题标题】:Develop a chrome extension to capture clicks using chrome extension api使用 chrome 扩展 api 开发 chrome 扩展以捕获点击
【发布时间】:2023-03-10 21:45:01
【问题描述】:

我正在尝试开发一个 chrome 扩展程序,它可以使用 chrome 扩展程序 API 而不是 JavaScript 来捕获点击。

【问题讨论】:

标签: google-chrome-extension


【解决方案1】:

如果您想在 chrome 扩展程序中捕获“点击”事件,这个答案可能会帮助您解决问题 - How may I get the element attributes (text, id, class and so on..) of the current tab, out of a mouse click, from a chrome extension?

在您的 content.js 中,编写以下代码-

$(window).click(function(event) {
    console.log("Click event: ", event);
});

Content scripts 是在网页上下文中运行的文件。通过使用标准文档对象模型 (DOM),他们能够读取浏览器访问的网页的详细信息,对其进行更改并将信息传递给其父扩展。

【讨论】: