Firefox JS 扩展 |如何访问 Firefox 的新选项卡和主页以注入我的新页面?
Firefox JS Extension | How do I access the new tab and the homepage of Firefox to inject my new page?
我一直在关注许多 Firefox 插件/扩展示例并搜索了 "tab" 文档;但是,我仍然没有找到如何使用我新创建的 index.html 页面作为 Firefox 的新标签页或主页。
我想创建类似 Momentum 的内容。 Firefox 的个人仪表板。
这就是我到目前为止所拥有的。但是,因为我在 tabs.onCreated
上创建了一个新标签,所以我在新标签中创建了一个无限循环。
Manifest.json
{
"description": "Adds browser action icon to toolbar to open packaged web page. See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples#open-my-page-button",
"manifest_version": 2,
"name": "Bookify",
"version": "1.0.0",
"homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/open-my-page-button",
"icons": {
"48": "icons/border-48.png"
},
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_icon": "icons/border-48.png"
},
"web_accessible_resources": [
"images/*.jpg",
"videos/*.mp4"
]
}
Background.js
function openMyPage() {
browser.tabs.create({
"url": "/dash.html"
});
}
browser.tabs.onCreated.addListener(openMyPage);
感谢 Ramkumar K R's answer on this 问题,我在 manifest.json 中实现了以下内容:
"chrome_url_overrides" : {
"newtab": "index.html"
}
因此,如果有人想知道如何在 Firefox 中更改新标签页,请使用 chrome_url_overrides。因为提到的问题还没有正式"answered",我会留下这个问题并自己回答,以便其他开发者可以在这里找到他们的答案。
我一直在关注许多 Firefox 插件/扩展示例并搜索了 "tab" 文档;但是,我仍然没有找到如何使用我新创建的 index.html 页面作为 Firefox 的新标签页或主页。
我想创建类似 Momentum 的内容。 Firefox 的个人仪表板。
这就是我到目前为止所拥有的。但是,因为我在 tabs.onCreated
上创建了一个新标签,所以我在新标签中创建了一个无限循环。
Manifest.json
{
"description": "Adds browser action icon to toolbar to open packaged web page. See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples#open-my-page-button",
"manifest_version": 2,
"name": "Bookify",
"version": "1.0.0",
"homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/open-my-page-button",
"icons": {
"48": "icons/border-48.png"
},
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_icon": "icons/border-48.png"
},
"web_accessible_resources": [
"images/*.jpg",
"videos/*.mp4"
]
}
Background.js
function openMyPage() {
browser.tabs.create({
"url": "/dash.html"
});
}
browser.tabs.onCreated.addListener(openMyPage);
感谢 Ramkumar K R's answer on this 问题,我在 manifest.json 中实现了以下内容:
"chrome_url_overrides" : {
"newtab": "index.html"
}
因此,如果有人想知道如何在 Firefox 中更改新标签页,请使用 chrome_url_overrides。因为提到的问题还没有正式"answered",我会留下这个问题并自己回答,以便其他开发者可以在这里找到他们的答案。