我見過the other question on here關於在Greasemonkey中加載jQuery。已經嘗試過的方法,用這種需要聲明我==UserScript==
標籤內:Greasemonkey @require jQuery不工作「組件不可用」
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
我仍然可以在Firefox的錯誤控制檯以下錯誤信息:
Error: Component is not available
Source File: file:///Users/greg/Library/Application%20Support/
Firefox/Profiles/xo9xhovo.default/gm_scripts/myscript/jquerymin.js
Line: 36
這會停止我的Greasemonkey代碼運行。我確定我包含了jQuery的@require
並在安裝之前保存了我的js文件,因爲所需文件只在安裝時加載。
代碼:
// ==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");
我的Greasemonkey 0.8.20091209.4安裝在Firefox 3.5.7上我的MacBook Pro,豹(10.5.8)。我清除了緩存(Cookie除外),並禁用了Flashblock 1.5.11.2,Web Developer 1.1.8和Adblock Plus 1.1.3以外的所有其他插件。
我3210與我的Greasemonkey腳本安裝:
<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>
我可以看到jquerymin.js坐在gm_scripts/myscript/
目錄。
此外,在安裝Greasemonkey腳本時,在控制檯中發生此錯誤常見嗎?
Error: not well-formed
Source File: file:///Users/Greg/Documents/myscript.user.js
Line: 1, Column: 1
Source Code:
// ==UserScript==
我試過你的腳本,它工作得很好。這裏沒問題,使用Greasemonkey版本0.8.20091129.3。你確定在安裝新腳本之前你已經正確地卸載了以前的腳本。我也在Firefox中緩存時遇到過麻煩。 – Anders 2010-01-16 15:14:47
這似乎是jquery 1.4的一個bug,幾天前剛剛發佈。至少,我有與jquery 1.4相同的問題,但不是與jquery 1.3。 – ShreevatsaR 2010-01-16 17:24:20