Chrome扩展错误加载Jquery [英] Chrome Extension Error Loading Jquery

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

问题描述

我正在研究一个Chrome扩展,并且我的内容脚本抛出一个错误

I am working on a chrome extension and my content script was throwing an error


$ / jQuery没有被定义。

$/jQuery not being defined.

所以我尝试使用我的清单文件来嵌入jquery,并且我在我的扩展文件夹中下载了jquery,但无论出于何种原因我收到此错误 - p>

So I tried embedding jquery using my manifest file and I downloaded jquery in my extension folder but for whatever reason I am receiving this error --


拒绝加载
chrome-extension://gfdmfdmhnoenciioooikdifmdkechdbl/jquery-1.10.2.min.map
必须在web_accessible_resources清单键
中列出资源,以便通过扩展名外的页面加载。

Denying load of chrome-extension://gfdmfdmhnoenciioooikdifmdkechdbl/jquery-1.10.2.min.map. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

我使用我的清单文件尝试了一些东西,但似乎没有任何工作,所以现在我试着这个,它仍然给我错误 - $ / b
$ b

I tried a couple of things with my manifest file but nothing seems to work so now Im trying this and its still giving me the error --

{
    "manifest_version": 2,

    "name":    "My Extension",
    "version": "0.0",
    "offline_enabled": false,

    "content_scripts": [{
        "matches":    ["*://*.sitedomain.com/*"],
        "js": [
                "jquery-1.10.2.min.js", 
                "content.js"
            ],
        "run_at":     "document_end",
        "all_frames": false
    }]
}

我无法编辑实际网站它的使用,所以我不能加载jquery头部的旧时尚方式,这就是为什么我试图加载扩展,所以我的内容脚本无线我会工作。任何帮助表示赞赏。

I am unable to edit the actual site its to be used on so I can't load jquery the old fashion way in the header, thats why Im trying to load with the extension so my content script will work. Any help is appreciated.

推荐答案

只需从jquery文件顶部删除此行

Just remove this line from the top of jquery file

//@ sourceMappingURL=jquery-1.10.2.min.map

如果您检查 Jquery 1.10.2 ,它在顶部包含源地图行。
我希望你没有使用源地图。有关更多详情,请查看以下链接:

If you check the source of Jquery 1.10.2, it has included source map line on the top. I hope you are not using Source Maps. For more details just check these links:


  1. http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/


  1. http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
  2. jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found)



替代方法



Alternate approach


  1. jquery下载页面下载源地图文件并在扩展目录中放置 jquery-1.10.2.min.map

  2. 下载未压缩的源代码并放入扩展目录中。

  3. 基本上你需要三个文件[SourceMap,Compressed,Uncompressed]。 >将这些映射文件路径和未压缩的文件路径添加到 web_ac cesible resources

  1. Download the source map file from jquery downloads page and put jquery-1.10.2.min.map in the extension directory.
  2. Download uncompressed source code as well and put in the extension directory.
  3. Basically you need three files [SourceMap, Compressed, Uncompressed].
  4. Add these map file path and uncompressed file paths to web_accesible resources.

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

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