javascript - 如何创建可以从弹出窗口打开新选项卡的 ReactJS chrome 扩展?
问题描述
我正在使用 ReactJS 创建一个 chrome 扩展。我基本上想要有两个页面 - 一个用于弹出窗口,第二个页面通过单击弹出窗口上的按钮在新选项卡中打开。
解决方案
首先,我建议遵循本教程的基础知识。
https://medium.com/@gilfink/building-a-chrome-extension-using-react-c5bfe45aaf36
这将对基础知识有很大帮助。一般的总结是,您希望将public 文件夹中的 manifest.json 更改为 chrome 扩展 manifest.json 的样子。在该 manifest.json 中,您希望添加 index.html(也在公用文件夹中)以在您真正希望调用它的任何地方调用。
下面的例子:
{
"manifest_version": 2,
"short_name": "XXX",
"name": "XXX",
"version": "1.0.2",
"browser_action": {
"default_popup": "index.html", //popup page occurs when you click on the favicon
"default_title": "Open the popup"
},
"chrome_url_overrides": {
"newtab": "index.html" //registers an override page (index.html) to the newtab page.
}
}
覆盖其他页面: https ://developer.chrome.com/extensions/override
注意:确保在使用 npm run build 构建它并在“Load Unpackaged”中选择 chrome 扩展时,您选择的是构建文件夹而不是公用文件夹。
推荐阅读
- kubernetes - 连接超时; 连接 CoreDNS 服务器时无法访问任何服务器
- javascript - 保存时使用字符串作为猫鼬模型的自定义 ID
- reinforcement-learning - 不同的策略迭代方法能否收敛到不同的最优策略?
- javascript - node.js 的导入语句不正确
- python - Django WebSocket DISCONNECT /ws/chat/lobby/ [127.0.0.1:3022]
- c - 字符串和整数的指针
- flutter - Flutter:在 gmail 中阅读电子邮件
- angular - 如何在角度垫步进器中显示默认图标而不是“完成”图标
- ruby-on-rails - 使用 Active Record 查询关联记录
- c++ - 如何为窗口截屏