Javascript 尝试使用Greasemonkey自动锁定

Javascript 尝试使用Greasemonkey自动锁定,javascript,greasemonkey,pinterest,Javascript,Greasemonkey,Pinterest,我正在尝试为Greasemonkey创建一个脚本,以便在Pinterest窗口打开时自动锁定 代码: 如果我在代码的末尾设置了一个console.log,它就会被执行,但是没有点击按钮 如果我通过Firebug控制台执行相同的指令,我会得到想要的效果。毫无疑问,Pinterest按钮是由AJAX添加的-在脚本运行很久之后 使用AJAX补偿技术等待它。下面是一个使用jQuery强大功能的完整脚本,单击该按钮: // ==UserScript== // @name YOUR_SCRIPT_N

我正在尝试为Greasemonkey创建一个脚本,以便在Pinterest窗口打开时自动锁定

代码:

如果我在代码的末尾设置了一个console.log,它就会被执行,但是没有点击按钮


如果我通过Firebug控制台执行相同的指令,我会得到想要的效果。

毫无疑问,Pinterest按钮是由AJAX添加的-在脚本运行很久之后

使用AJAX补偿技术等待它。下面是一个使用jQuery强大功能的完整脚本,单击该按钮:

// ==UserScript==
// @name     YOUR_SCRIPT_NAME
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant    GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
    introduced in GM 1.0.   It restores the sandbox.
*/

waitForKeyElements ("button[data-text-pin-it]", clickPinterestBtn);

function clickPinterestBtn (jNode) {
    jNode[0].click ();
}

同样的问题。。。我在函数中设置了console.logjNode,它显示了按钮,但没有单击它!编辑:它在Chrome中工作,而不是在Firefox中!!你在用猴子吗?如果不是,那是不可能的。如果它在Firefox+GM中不起作用,但在Chrome+Tampermonkey中起作用,那么@required文件可能没有被复制到GM中的已知错误中。请按照中的方法重新安装脚本。
// ==UserScript==
// @name     YOUR_SCRIPT_NAME
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant    GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
    introduced in GM 1.0.   It restores the sandbox.
*/

waitForKeyElements ("button[data-text-pin-it]", clickPinterestBtn);

function clickPinterestBtn (jNode) {
    jNode[0].click ();
}