我有自己的 javascript,需要用 Greasemonkey 进行测试。我以前从未与 Greasemonkey 合作过;我如何测试脚本?
我没有在万维网上测试它,我已经保存了目标页面(Firefox > 将页面另存为 > 网页,完成),所以我在本地测试它。
流程是怎样的?我如何测试脚本?
以下是一些针对 Greasemonkey 脚本进行故障排除的指南,包括一般情况和网页本地副本上的问题。
为了在本地页面上进行测试(没有本地网络服务器),您必须更改 Greasemonkey 的设置。
Open 关于:配置 http://kb.mozillazine.org/About:config并设置greasemonkey.fileIsGreaseable
to true
确保该网页的本地副本不在系统中/tmp
or /temp
文件夹。如果是的话,该脚本将无法可靠地工作。
确保脚本源不在系统中/tmp
or /temp
文件夹。如果是的话,该脚本将不会安装 http://wiki.greasespot.net/Troubleshooting_%28Script_Authors%29#Installing_from_.2Ftmp.
-
要使脚本能够处理本地文件,请确保您有合适的@include指示 http://wiki.greasespot.net/Metadata_Block#.40include针对本地网页复制。例如:
// @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 https://stackoverflow.com/a/9627507/331508.
Install Firebug https://www.getfirebug.com/并熟悉它。Firebug优秀的控制台功能 http://getfirebug.com/wiki/index.php/Console_API在 GM 脚本中工作得很好——尽管你might必须在它们前面加上unsafeWindow.
.
尽可能多地测试 javascript,但不使用GM_函数 http://wiki.greasespot.net/Category:API_Reference,首先在 Firebug 的 JavaScript 控制台中。
也可以看看:
- 脚本作者的故障排除 http://wiki.greasespot.net/Troubleshooting_%28Script_Authors%29
- 避免 Greasemonkey 中的常见陷阱 http://wiki.greasespot.net/Avoid_Common_Pitfalls_in_Greasemonkey
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)