如何测试Greasemonkey脚本,特别是在本地的网页副本上? [英] How to test a Greasemonkey script, especially on a local copy of a webpage?

查看:169
本文介绍了如何测试Greasemonkey脚本,特别是在本地的网页副本上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有自己的javascript,我需要用Greasemonkey测试。我从来没有和Greasemonkey一起工作我如何测试脚本?



我没有在万维网上测试,我已经保存了目标页面( Firefox>将页面另存为> Web页面,完成),所以我在本地测试。



过程是什么?如何测试脚本?

解决方案

以下是一些针对Greasemonkey脚本进行故障诊断的指导原则,一般来说,本地副本


  1. 为了在本地页面(没有本地Web服务器)进行测试,您必须更改Greasemonkey的设置。 br>
    打开 about:config 并设置 greasemonkey.fileIsGreaseable true


  2. 确保网页的本地副本不在系统的 / tmp / temp 文件夹。


  3. 确保脚本源不在系统的 / tmp / temp 文件夹。 脚本将不会安装,如果是


  4. 要使脚本处理本地文件,请确保您具有适当的 @包含针对本地网页副本的指令。例如:

      // @include file:/// D:/ web / local%20page%20copies / * $ b熟悉Firefox的错误控制台( Ctrl   Shift   

    / kbd> J )和如何使用它来确定Greasemonkey脚本中的错误来源


  5. 安装 Firebug 并熟悉它。 Firebug的出色的控制台功能在GM脚本中非常出色 - 尽管您可能拥有用 unsafeWindow来表达它们。


  6. 尽可能多地测试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.

  1. For testing on local pages (without a local web-server), you must change a setting of Greasemonkey.
    Open about:config and set greasemonkey.fileIsGreaseable to true

  2. 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.

  3. Make sure the script source is not in the system's /tmp or /temp folder(s). The script will not install if it is.

  4. 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/*
    

  5. Familiarize yourself with Firefox's error console (CtrlShiftJ) and how it can be used to determine the source of errors in Greasemonkey scripts.

  6. 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..

  7. 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆