gpt4 book ai didi

google-chrome - 使用 chrome 扩展向页面添加按钮

转载 作者:行者123 更新时间:2023-12-04 20:10:25 69 4
gpt4 key购买 nike

是否可以将带有 onclick 事件的简单按钮添加到带有 chrome 扩展的页面?

例如,如果我正在看

google.com


var google = document.getElementById("main");
var button = document.createElement("button");
var text = document.createTextNode("test");
button.appendChild(text);
google.appendChild(button);

我看到我的按钮了吗?

最佳答案

您可以在 content script 中使用该代码设置为在特定网页上运行。

Content scripts are JavaScript files that run in the context of webpages. By using the standard Document Object Model (DOM), they canread details of the web pages the browser visits, or make changes tothem.

关于google-chrome - 使用 chrome 扩展向页面添加按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18174152/

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