[英]How to test a Greasemonkey script, especially on a local copy of a webpage?
I have my own javascript that I need to test with Greasemonkey. 我有自己的javascript,我需要用Greasemonkey测试。 I've never worked with Greasemonkey before;
我以前从未和Greasemonkey合作过; 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. 我没有在万维网上测试它,我保存了目标页面( Firefox>保存页面为>网页,完成 ),所以我在本地测试它。
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. 以下是Greasemonkey脚本(一般情况下)和本地网页副本的故障排除指南。
For testing on local pages (without a local web-server), you must change a setting of Greasemonkey. 要在本地页面上进行测试(没有本地Web服务器),您必须更改Greasemonkey的设置。
Open about:config and set greasemonkey.fileIsGreaseable
to true
打开about:config并将
greasemonkey.fileIsGreaseable
设置为true
Make sure the local copy of the webpage is not in the system's /tmp
or /temp
folder(s). 确保网页的本地副本不在系统的
/tmp
或/temp
文件夹中。 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). 确保脚本源不在系统的
/tmp
或/temp
文件夹中。 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. 要使脚本处理本地文件,请确保您具有针对本地网页副本的适当
@include
指令 。 For example: 例如:
// @include file:///D:/web/local%20page%20copies/*
Familiarize yourself with Firefox's error console ( Ctrl Shift J ) and how it can be used to determine the source of errors in Greasemonkey scripts . 熟悉Firefox的错误控制台( Ctrl Shift J )以及如何使用它来确定Greasemonkey脚本中的错误来源 。
Install Firebug and get familiar with it. 安装Firebug并熟悉它。 Firebug's excellent console functions work great from within a GM script -- although you might have to preface them with
unsafeWindow.
Firebug的出色控制台功能在GM脚本中运行良好 - 尽管您可能必须使用
unsafeWindow.
作为前言unsafeWindow.
. 。
Test as much of the javascript as you can, that doesn't use GM_ functions , in Firebug's JavaScript console first. 首先在Firebug的JavaScript控制台中测试尽可能多的javascript,它不使用GM_函数 。
See also: 也可以看看:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.