【问题标题】:Your first extension - official Firefox extension tutorial not working您的第一个扩展 - 官方 Firefox 扩展教程不起作用
【发布时间】:2020-03-21 16:36:14
【问题描述】:

我想尝试学习如何制作浏览器扩展并尝试做第一个官方教程https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension

当关注此处的所有内容并进入 mozilla.org 域时,扩展程序不会在站点周围放置红色边框。它基本上什么都不做。 (我知道 addon.mozilla.org 上禁用了内容脚本)

我已仔细按照教程的每个步骤进行操作。

这里是教程的存储库:https://github.com/mdn/webextensions-examples/tree/master/borderify

我只是想验证一下我是否是唯一一个无法使用本教程的人。

【问题讨论】:

    标签: firefox firefox-addon-sdk firefox-addon-webextensions


    【解决方案1】:

    教程很好。您可以尝试将其更改为另一个站点并再次测试。例如:

    {
    
      "description": "Adds a solid red border to all webpages matching mozilla.org. See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples#borderify",
      "manifest_version": 2,
      "name": "Borderify",
      "version": "1.0",
      "homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/borderify",
      "icons": {
        "48": "icons/border-48.png"
      },
    
      "content_scripts": [
        {
          "matches": ["*://*.example.com/*"],
          "js": ["borderify.js"]
        }
      ]
    
    }
    

    那就去https://example.com/测试吧。

    【讨论】:

    • 它不起作用。我一直在使用 about:debugging 中的加载临时插件加载扩展。你知道为什么它对我不起作用吗?
    • @Nassims 我现在测试了用"matches": ["*://*.example.com/*"] 临时加载的同一个扩展,它工作正常。点击 INSPECT 并检查是否有任何错误。
    • 它什么也不做,控制台也没有错误。
    • @Nassims 然后某处出现错误。是否将扩展打包到 xpi 中或使用解压并在 about:debugging 中从加载临时插件中打开 manifest.json
    • 我在 about:debugging 中使用加载临时插件中解压并打开的 manifest.json。
    【解决方案2】:

    我遇到了同样的问题:Borderify 示例不起作用。就我而言,这是我的默认浏览器隐私设置的问题。

    尝试进入 Firefox 设置并查看选项始终使用私人模式是否被禁用。

    或者,在调试模式下加载扩展后,转到附加组件部分并为私人窗口启用扩展

    【讨论】:

      猜你喜欢
      • 2016-03-06
      • 2011-08-18
      • 2020-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多