无法安装我的自定义Chrome扩展程序crx_magic_number_invalid

时间:2014-01-31 08:47:34

标签: google-chrome google-chrome-extension

我做了一个简单的chrome扩展程序:

的manifest.json:

{
  "name": "Layout VS Design",
  "version": "1",
  "description": "Enter the url of a image with your design at 100%",
  "background_page": "index.html",
  "browser_action": {
    "name": "Manipulate DOM",
    "icons": ["icon.png"],
    "default_icon": "icon.png"
  },
  "content_scripts": [ {
    "js": [ "jquery.min.js", "js.js" ],
    "matches": [ "http://*/*", "https://*/*"]
  }]
}

问题是chrome不会让我安装它: enter image description here

问题是我不知道在哪里设置这个数字,不知道我能尝试什么?

2 个答案:

答案 0 :(得分:6)

我看到的第一件事是你的background_page格式不正确。它应该是

{ ...

   "background": {
       "page": "index.html"
    },
    ...
}

如果manifest.json文件格式不正确,Chrome会拒绝该扩展程序。

您可以在Google的Manifest File Format文档中详细了解清单格式。

更新

Another SO post详细介绍了Chrome在.crx文件顶部查找“幻数”的方法。但是,如果您在本地托管,则可以更简单的方式安装扩展程序。

  • manifest.jsonbackground.html保存到目录(名称无关紧要)
  • 转到chrome:extensions
  • 确保在顶部检查“开发者模式”
  • 点击“加载未打包的扩展程序...”
  • 选择要在Chrome上安装backgroundmanifest个文件的目录。

答案 1 :(得分:2)

  1. 转到扩展程序页面
  2. 检查开发人员选项
  3. 点击包扩展
  4. 设置根目录(图像和清单文件所在的文件夹) 存在)
  5. pack extension
  6. 现在禁用开发人员选项
  7. 转到根目录(不要打开根目录,只是这样说 您可以轻松找到文件,否则您可以打开它)
  8. 您将看到.crx文件只需使用chrome打开它(例如将此文件拖放到chrome://extensions/页面上)
  9. 点击继续(将出现在Chrome窗口的底部)
  10. 您的Chrome浏览器已按您的需要进行修改

相关问题