2012-08-06 62 views
5

我有我自己的JavaScript,我需要使用Greasemonkey進行測試。我從來沒有與Greasemonkey合作過;我如何測試腳本?我不保存目標頁面(Firefox>保存頁面爲>網頁,完成),所以我在本地測試它。如何測試Greasemonkey腳本,特別是在網頁的本地副本上?

這是什麼過程?我如何測試腳本?

+1

這是一個SO相當寬泛的問題。也許你最好通過Greasemonkey文檔和教程? – Jeroen 2012-08-06 22:46:05

回答

6

以下是一般故障排除指南,以及本地的網頁副本。

  1. 要在本地頁面(沒有本地Web服務器)上進行測試,必須更改Greasemonkey的設置。
    打開about:config,並設置greasemonkey.fileIsGreaseabletrue

  2. 確保網頁的本地副本不是在系統的/tmp/temp文件夾(S)。如果是的話,腳本將無法可靠地工作。

  3. 確保腳本源不在系統的/tmp/temp文件夾中。 The script will not install if it is

  4. 對於腳本來處理本地文件,請確保您有一個適當的@include directive針對本地網頁副本。例如:

    // @include file:///D:/web/local%20page%20copies/* 
    
  5. 熟悉Firefox的錯誤控制檯(按Ctrl Ĵ)和how it can be used to determine the source of errors in Greasemonkey scripts

  6. 安裝Firebug並熟悉它。 Firebug's excellent console functions在GM腳本中很有效 - 儘管可能必須以unsafeWindow.開頭。

  7. 測試儘可能多的JavaScript的就可以了,不首先使用GM_ functions,在Firebug的JavaScript控制檯。


參見: