【问题标题】:I'm having trouble with my extension我的扩展程序有问题
【发布时间】:2016-02-18 02:30:51
【问题描述】:

所以,我一直在开发一个小的 Google Chrome 扩展程序,用其他词替换一些词,但是当我尝试加载扩展程序时,Google 告诉我有一个“Manifest is not valid JSON. Line: 12 ,列:2,根元素后的意外数据。"错误,我无法修复它。谢谢!

   //credit goes to /u/adamrsb48

{
  "manifest_version": 2,
  "name": "Random Plugins",
  "version": "0.1"
 "background": {
    "scripts": ["background.js"],
    "persistent": false
}
  "content_scripts": [
    {
        "matches": ["http://*/*", "https://*/*"],
        "js": ["plugins.js"]
    }
]


}

【问题讨论】:

  • 您在background 对象的右大括号和"content_scripts" 键之间缺少,,在值"0.1" 和键之间也缺少"background" 键:"background"

标签: javascript google-chrome-extension


【解决方案1】:

您缺少两个逗号;在“版本”之后:“0.1”和“背景”之后:{...}

试试这个:

{
  "manifest_version": 2,
  "name": "Random Plugins",
  "version": "0.1",
  "background": {
    "scripts": [
      "background.js"
    ],
    "persistent": false
  },
  "content_scripts": [
    {
      "matches": [
        "http://*/*",
        "https://*/*"
      ],
      "js": [
        "plugins.js"
      ]
    }
  ]
}

【讨论】:

    【解决方案2】:

    你在某个地方错过了, 我帮你修好了

    {
    	"manifest_version": 2,
    	"name": "Random Plugins",
    	"version": "0.1",
    	"background": {
    		"scripts": ["background.js"],
    		"persistent": false
    	},
    	"content_scripts": [{
    		"matches": ["http://*/*", "https://*/*"],
    		"js": ["plugins.js"]
    	}]
    
    
    }

    您可以使用this 来检查有效的 JSON

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-11
      • 1970-01-01
      • 1970-01-01
      • 2015-12-01
      • 2017-11-18
      • 1970-01-01
      • 2022-01-10
      相关资源
      最近更新 更多