【问题标题】:How to debug Greasemonkey script on Firefox 30?如何在 Firefox 30 上调试 Greasemonkey 脚本?
【发布时间】:2014-06-21 11:37:38
【问题描述】:

我一直在为 Youtube 开发一个 JavaScript sn-p,它使用 Greasemonkey,还导入了 Bootstrap 和 jQuery 库。此应用程序必须为每个搜索列表结果添加一个按钮,并且当用户单击它时,它必须将用户上传的视频从他的频道带入。我已经测试了这个按钮,它在 Firefox 29 上运行良好。

尽管如此,最近我将 Firefox 更新到版本 30,现在我无法查看/调试我编写的代码,尽管 Firefox 会执行它。我想知道,这个问题有什么解决办法吗?

如果你想看,这里是代码:

// ==UserScript==
// @name Requerimiento2-2-Guille.user.js
// @description   Rodrigo
// @include         http://www.youtube.com/*
// @include         https://www.youtube.com/*
// @grant           none
// ==/UserScript== 

/* Here it's the Bootstrap and jQuery code pasted (I know it should be done with an include).*/

var boton='<button  style="float:right;" type="button" class="verVideos btn btn-lg yt-uix-button yt-uix-button-size-default yt-uix-button-primary">'+'<span class="glyphicon glyphicon-list"></span>Ver videos del usuario'+
    '</button>';

    $(function(){
        iniciarScript();
    });
    function iniciarScript(){
        $("#search-results li.yt-lockup div.yt-lockup-content").before(boton);
        $("#verVideos").click(mostrarVideosUsr);
    }
    function mostrarVideosUsr(){        
        alert("Se pulso el boton!");
    }

PD:我尝试使用其他用户配置文件启动 Firefox,但始终无法正常工作。

【问题讨论】:

  • 您如何尝试“查看”代码?什么版本的 Greasemonkey? (GM 2 刚刚发布,它改变了一些事情。)
  • 你好@BrockAdams,我正在尝试使用 Firebug 1.12.18 定位和调试我的代码,而我正在使用 GM 1.15。
  • 这个问题与"How to debug Greasemonkey script with the Firebug extension?" then 是重复的。除了 FF 30 给人们带来悲伤。如果有人没有打败我,稍后会调查。
  • 是的,它确实如此,这就是我重新发布该问题的原因。我一直在搜索的解决方案都不适用于所有其他 Firefox 版本较旧的版本。

标签: jquery twitter-bootstrap debugging firefox greasemonkey


【解决方案1】:

我发现实际执行此操作的唯一方法(v.42)是使用远程调试系统。如果你想重现:

  1. 无需插件即可创建配置文件以显着提高速度。
  2. 在上面安装greasemonkey插件。
  3. 使用远程调试:https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging/Debugging_Firefox_Desktop
  4. 使用另一个 firefox 配置文件启动 webIDE,调试同一配置文件没有成功。
  5. 远程调试配置文件 1..选择“打开应用程序”>“运行时应用程序”时,选择主进程。

您的脚本将出现在“file://”下的调试器选项卡中。您将能够设置断点、间谍、...

【讨论】:

    【解决方案2】:

    或者,如果您只是想调试您的脚本,那么您可以将 Chrome 与 Tampermonkey 一起使用。

    Tampermonkey 的工作方式与 Greasemonkey 几乎相同,因此如果您的脚本在 Tampermonkey 上运行,它应该在 Greasemonkey 上运行。

    请记住,如果从文件系统安装,那么您需要启用 Tampermonkey 的访问权限。请参阅常见问题解答中有关如何启用此功能的视频: http://tampermonkey.net/faq.php#Q204

    【讨论】:

      猜你喜欢
      • 2014-09-23
      • 1970-01-01
      • 1970-01-01
      • 2011-03-30
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      • 2019-06-26
      • 1970-01-01
      相关资源
      最近更新 更多