将 JQuery 加载到 Chrome 扩展程序中? [英] Load JQuery into a Chrome extension?

查看:29
本文介绍了将 JQuery 加载到 Chrome 扩展程序中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 JQuery 加载到我的 Chrome 扩展程序中并使其等于一个对象,但我想知道我将如何处理?基本上我想要像......

I'm attempting to load JQuery into my Chrome extension and make it equal to an object but I'm wondering how would I go about this? basically I'd like something like...

jQuery = loadLibraries("jquery-1.4.2.min.js");

我该怎么做?

我正在注入内容脚本.

推荐答案

您可以将 jquery.js 放入扩展文件夹并将其包含在清单中:

You can just put jquery.js into extension folder and include it in the manifest:

{
  "name": "My extension",
  ...
  "content_scripts": [
    {
      "matches": ["http://www.google.com/*"],
      "css": ["mystyles.css"],
      "js": ["jquery.js", "myscript.js"]
    }
  ],
  ...
}

您无需担心与父页面上的 jQuery 冲突,因为内容脚本已被沙盒化.

You don't need to worry about conflicts with jQuery on a parent page as content scripts are sandboxed.

这篇关于将 JQuery 加载到 Chrome 扩展程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆