Greasemonkey @require jQuery不工作“组件不可用” [英] Greasemonkey @require jQuery not working "Component not available"

查看:164
本文介绍了Greasemonkey @require jQuery不工作“组件不可用”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到这里的其他问题关于loading在Greasemonkey中的jQuery。已经尝试过这种方法,在 == UserScript == 标签中使用这个require语句:

  // @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js 

我仍然在Firefox的错误控制台中收到以下错误消息:

 错误:Component不可用
源文件:file:/// Users / greg / Library / Application%20Support /
Firefox / Profiles / xo9xhovo.default / gm_scripts / myscript / jquerymin.js
Line: 36

这会阻止我的greasemonkey程序运行。我已经确定我包含了jQuery的 @require ,并在安装之前保存了我的js文件,因为所需的文件只在安装时加载。



代码:

  // == UserScript == 
// @name My脚本
// @namespace http://www.google.com
// @description我的测试脚本
// @include http://www.google.com
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// == / UserScript ==

GM_log(你好);

我在我的Macbook Pro,Leopard(10.5)上安装了Firefox 3.5.7上的Greasemonkey 0.8.20091209.4。 8)。我已经清除了缓存(Cookie除外),并禁用了Flashblock 1.5.11.2,Web Developer 1.1.8和Adblock Plus 1.1.3以外的所有其他插件。



我的 config.xml 安装了我的Greasemonkey脚本:

 < UserScriptConfig> 
< Script filename =myscript.user.jsname =My Script
namespace =http://www.google.comdescription =我的测试脚本enabled =true
basedir =myscript>
<包含> http://www.google.com< /包含>
<要求文件名=jquerymin.js/>
< / Script>



我可以看到jquerymin.js坐在 gm_scripts / myscript / 目录中。



另外,在控制台当安装Greasemonkey脚本?

$ p $ 错误:格式不正确
源文件:file:///用户/ Greg / Documents / myscript.user.js
行:1,列:1
源代码:
// == UserScript ==


解决方案

好的,我深入了解了这一点。我使用了你的脚本,但是使用了我们的JQuery版本,看起来像这样:
$ b $ $ $ $ $ $ $ $ $ $ $ $ UserScript ==
// @name我的脚本
// @namespace http://www.google.com
// @description我的测试脚本
// @include http:// www .google.se / *
// @include http://www.dn.se/*
// @require http://myserver/jquery-1.3.2.js
// == / UserScript ==

GM_log(Hello);

这对我来说很好,我的猜测是,在google api上的JQuery缺少一些函数。因为上面的代码,工作得很好。还要注意每个url结尾处的 / * ,请包括它。



尝试另一个JQuery并更改它应该世界正常。


I've seen the other question on here about loading jQuery in a Greasemonkey. Having tried that method, with this require statement inside my ==UserScript== tags:

// @require    http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js

I still get the following error message in Firefox's error console:

Error: Component is not available
Source File: file:///Users/greg/Library/Application%20Support/
       Firefox/Profiles/xo9xhovo.default/gm_scripts/myscript/jquerymin.js
Line: 36

This stops my greasemonkey code from running. I've made sure I included the @require for jQuery and saved my js file before installing it, as required files are only loaded on installation.

Code:

// ==UserScript==
// @name           My Script
// @namespace      http://www.google.com
// @description    My test script
// @include        http://www.google.com
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// ==/UserScript==

GM_log("Hello");

I have Greasemonkey 0.8.20091209.4 installed on Firefox 3.5.7 on my Macbook Pro, Leopard (10.5.8). I've cleared my cache (except cookies) and have disabled all other plugins except Flashblock 1.5.11.2, Web Developer 1.1.8 and Adblock Plus 1.1.3.

My config.xml with my Greasemonkey script installed:

<UserScriptConfig>
<Script filename="myscript.user.js" name="My Script" 
 namespace="http://www.google.com" description="My test script" enabled="true" 
 basedir="myscript">
    <Include>http://www.google.com</Include>
    <Require filename="jquerymin.js"/>
</Script>

I can see jquerymin.js sat in the gm_scripts/myscript/ directory.

Additionally, is it common for this error to occur in the console when installing a Greasemonkey script?

Error: not well-formed
Source File: file:///Users/Greg/Documents/myscript.user.js
Line: 1, Column: 1
Source Code:
   // ==UserScript==

解决方案

Ok, so i looked into this a bit more deeper. I used your script exactly, but used our JQuery version, making it look like this:

// ==UserScript==
// @name           My Script
// @namespace      http://www.google.com
// @description    My test script
// @include        http://www.google.se/*
// @include        http://www.dn.se/*
// @require        http://myserver/jquery-1.3.2.js
// ==/UserScript==

GM_log("Hello");

This works just fine for me, my guess, the JQuery up on the google api is missing some functions. Because this code above, works just fine. Also note the /* at the end of each url, please include that.

Try another JQuery and change the urls and it should world properly.

这篇关于Greasemonkey @require jQuery不工作“组件不可用”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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