How to debug Greasemonkey script on Firefox 30?

蹲街弑〆低调 提交于 2019-12-21 05:38:05

问题


I've been developing a JavaScript snippet for Youtube which uses Greasemonkey, and also imports Bootstrap and jQuery libraries. This application has to add a button for each one of the search list results and when the user clicks it, it must bring the user uploaded videos from his channel. I've tested the button and it works well on Firefox 29.

Nevertheless, recently I updated Firefox to version 30, and now I'm unable to see/debug the code I wrote, although Firefox executes it. I'd like to know, if is there any solution to this issue?

Here is the code if you would like seeing it:

// ==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: I've tried starting Firefox with other user profile, but it keeps not working.


回答1:


The only way I found to do it actually (v.42) is to use the remote debugging system. If you want to reproduce:

  1. create a profile without addon to considerably increase speed.
  2. install greasemonkey addon on it.
  3. use remote debugging: https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging/Debugging_Firefox_Desktop
  4. use another firefox profile to start webIDE, no success in debugging same profile.
  5. distant debug the profile in 1..While selecting go "Open app" > "RUNTIME APPS", select main process.

Your script will appear in the debugger tab under "file://". You will be able to set breakpoints, spy, ...




回答2:


Or if you simply want to debug your script then you can use Chrome with Tampermonkey.

Tampermonkey works almost identical to Greasemonkey so if your script works on Tampermonkey it should work on Greasemonkey.

Just remember that if install from file system then you need to enable access for Tampermonkey. See video in the FAQ on how to enable this: http://tampermonkey.net/faq.php#Q204



来源:https://stackoverflow.com/questions/24341199/how-to-debug-greasemonkey-script-on-firefox-30

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!