如何将jQuery插件添加到Chrome扩展Manifest.json

时间:2014-02-12 19:05:17

标签: jquery google-chrome google-chrome-extension google-chrome-app

您能否告诉我如何将jQuery插件添加到Google Chrome扩展程序manifest.json文件中?

{
  "manifest_version": 2,

  "name": "One Pass",
  "description": "This is a Development.",
  "version": "1.0",

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },
  "permissions": [
    "https://secure.flickr.com/"
  ]
}

谢谢,

1 个答案:

答案 0 :(得分:3)

您需要将其添加为内容脚本。它在chrome中有很好的记录:http://developer.chrome.com/extensions/tut_migration_to_manifest_v2.html。最简单的方法是保留jquery的本地副本并将其与扩展一起发送,然后在manifest.json中引用它,如下所示:

 "content_scripts": [
    {
    "all_frames": false,
    "matches": ["<all_urls>"],
    "exclude_matches": [],
      "js": [
        "js/lib/jquery.js"
      ],

      "css": [
        "js/content/page.css"
      ]
    }
  ]