我一直在为 Youtube 开发一个 JavaScript 片段,它使用 Greasemonkey,并且还导入了 Bootstrap 和 jQuery 库。该应用程序必须为每个搜索列表结果添加一个按钮,当用户单击该按钮时,它必须带出用户从其 channel 上传的视频。我已经测试过该按钮,它在 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,但始终无法正常工作。
最佳答案
我发现实际执行此操作的唯一方法(v.42)是使用远程调试系统。如果您想重现:
- 创建一个不带插件的配置文件以显着提高速度。
- 在其上安装greasemonkey插件。
- 使用远程调试:https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging/Debugging_Firefox_Desktop
- 使用另一个firefox配置文件启动webIDE,调试相同的配置文件没有成功。
- 远程调试1中的配置文件。选择“打开应用程序”>“运行时应用程序”时,选择主进程。
您的脚本将出现在“file://”下的调试器选项卡中。您将能够设置断点、监视……
关于jquery - 如何在 Firefox 30 上调试 Greasemonkey 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24341199/