如何测试Greasemonkey脚本,特别是在本地的网页副本上? [英] How to test a Greasemonkey script, especially on a local copy of a webpage?
问题描述
我没有在万维网上测试,我已经保存了目标页面( Firefox>将页面另存为> Web页面,完成),所以我在本地测试。
过程是什么?如何测试脚本?
以下是一些针对Greasemonkey脚本进行故障诊断的指导原则,一般来说,本地副本
-
为了在本地页面(没有本地Web服务器)进行测试,您必须更改Greasemonkey的设置。 br>
打开 about:config 并设置greasemonkey.fileIsGreaseable
到true
-
确保网页的本地副本不在系统的
/ tmp
或/ temp
文件夹。 -
确保脚本源不在系统的
/ tmp
或/ temp
文件夹。 脚本将不会安装,如果是。 -
要使脚本处理本地文件,请确保您具有适当的
@包含针对本地网页副本的
指令。例如:// @include file:/// D:/ web / local%20page%20copies / * $ b熟悉Firefox的错误控制台( Ctrl Shift
/ kbd> J )和如何使用它来确定Greasemonkey脚本中的错误来源。
-
安装 Firebug 并熟悉它。 Firebug的出色的控制台功能在GM脚本中非常出色 - 尽管您可能拥有用
unsafeWindow来表达它们。
。 -
尽可能多地测试javascript,不要在Firebug的JavaScript控制台中使用 GM_功能。
另请参阅
I have my own javascript that I need to test with Greasemonkey. I've never worked with Greasemonkey before; How do I test the script?
I am not testing it on the World Wide Web, I have saved the target page (Firefox > Save page as > Web page, complete), so I am testing it locally.
What is the process? How do I test the script?
Here are some guidelines for troubleshooting Greasemonkey scripts, both in general, and on local copies of webpages.
For testing on local pages (without a local web-server), you must change a setting of Greasemonkey.
Open about:config and setgreasemonkey.fileIsGreaseable
totrue
Make sure the local copy of the webpage is not in the system's
/tmp
or/temp
folder(s). The script will not work reliably, if it is.Make sure the script source is not in the system's
/tmp
or/temp
folder(s). The script will not install if it is.For a script to work on local files, be sure you have an appropriate
@include
directive aimed at the local webpage copy. For example:// @include file:///D:/web/local%20page%20copies/*
Familiarize yourself with Firefox's error console (CtrlShiftJ) and how it can be used to determine the source of errors in Greasemonkey scripts.
Install Firebug and get familiar with it. Firebug's excellent console functions work great from within a GM script -- although you might have to preface them with
unsafeWindow.
.Test as much of the javascript as you can, that doesn't use GM_ functions, in Firebug's JavaScript console first.
See also:
这篇关于如何测试Greasemonkey脚本,特别是在本地的网页副本上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!