为什么不能安装这个chrome扩展?

时间:2013-09-23 19:44:24

标签: javascript json google-chrome google-chrome-extension

我有一些非常短的+简单的扩展,我无法安装到chrome。关于'清单版本'我有以下错误,所以我认为问题是它已经过时了,我没有任何chrome扩展/ javascript的经验所以我无法自己修复它们,因为我通常会尝试这些都是朋友回来后为我写的。

有人可以告诉我应该如何纠正这些文件吗?

错误:

The 'manifest_version' key must be present and set to 2 (without quotes). See developer.chrome.com/extensions/manifestVersion.html for details.

扩展文件:

manifest.json for extension 1:

{
"content_scripts": [ {
  "exclude_globs": [  ],
  "include_globs": [ "*slavehack*index2.php\\?page=internet&openFolder=&var3=files&aktie=*&*=*" ],
  "js": [ "script.js" ],
  "matches": [ "http://*/*", "https://*/*" ]
} ],
"converted_from_user_script": true,
"description": "",
"key": "XKBlE2kyhcJNHGYLuLylZhjFVQV7puTEQbsFuGRcKoY=",
"name": "Slavehack Process Log Protector",
"version": "1.0"
}

script.js for extension 1:

// ==UserScript==
// @name           Slavehack Process Log Protector
// @include        *slavehack*index2.php?page=internet&openFolder=&var3=files&aktie=*&*=*
// @version                1.0
// ==/UserScript==
var allA = document.getElementsByTagName('a');
for (var i = 0; i < allA.length; i++) {
    if ( allA[i].innerHTML.match('Access logfile') ) {
        window.location.href = allA[i].href;
    }
}

manifest.json for extension 2:

{
  "content_scripts": [ {
  "exclude_globs": [  ],
  "include_globs": [ "*slavehack*index2.php\\?page=internet&var3=&aktie=FP&var2=*&transfer=*&tonumber=*&toip=*" ],
  "js": [ "script.js" ],
  "matches": [ "http://*/*", "https://*/*" ]
   } ],
   "converted_from_user_script": true,
   "description": "",
   "key": "WxQnzwPDzxXFW/TSZw6dNJJJSyVIXlub/QQGMlVtjbc=",
   "name": "Bank IP Log Crack Remover",
   "version": "1.0"
}

script.js for extension 2:

// ==UserScript==
// @name           Bank IP Log Crack Remover
// @include        *slavehack*index2.php?page=internet&var3=&aktie=FP&var2=*&transfer=*&tonumber=*&toip=*
// @version                1.0
// ==/UserScript==
var bankip = window.location.href.split('=')[window.location.href.split('=').length - 1]
window.location.href = 'http://www.slavehack.com/index2.php?page=internet&var2='+bankip.replace('#','')+'&var3=crack&var4=';

非常感谢您的帮助

2 个答案:

答案 0 :(得分:11)

错误消息不言自明:

  

'manifest_version'键必须存在并设置为2(不带引号)。   有关详细信息,请参阅developer.chrome.com/extensions/manifestVersion.html

referenced documentation在页面顶部提供了一个非常明确的示例:

{
  ...,
  "manifest_version": 2,
  ...
}

这些点表示为了示例省略了manifest file的部分。您必须编辑manifest.json文件,并在文件中的某处插入"manifest_version": 2

例如,在您的情况下,您可以在"version"键之前添加一行,并在其上添加"manifest_version": 2声明。

   ...
   "manifest_version": 2,
   "version": "1.0"
}

请注意,该行末尾有一个逗号。在JSON数据格式中,每个名称/值对都用逗号分隔。

答案 1 :(得分:0)

加入你的“manifest.json&#39;:

'manifest_version': 2

示例:

{
    "name": "name your extension",
    "version": "1.0",
    "description": "description your building",
    "manifest_version": 2,
    "browser_action":{
       "default_icon": "icon777.png",
       "popup": "body.html"
    }
 }