簡體   English   中英

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 KR這個問題的回答,我在manifest.json中實現了以下內容:

"chrome_url_overrides" : {
   "newtab": "index.html"
 }

因此,如果有人想知道如何更改Firefox中的newtab頁面,請使用chrome_url_overrides 由於提到的問題尚未正式“回答”,我將留下這個問題並自己回答,以便其他開發人員可以在這里找到他們的答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM