使用Javascript跟踪Ajaxify链接
我正在尝试创建一个greasemonkey脚本,该脚本将自动戳(好吧,repoke)facebook上的用户。然而,这只是我指定的特定人员。这很容易做到,因为我可以使用特定的uid显示显示戳的HTML,具体如下:使用Javascript跟踪Ajaxify链接,javascript,ajax,greasemonkey,Javascript,Ajax,Greasemonkey,我正在尝试创建一个greasemonkey脚本,该脚本将自动戳(好吧,repoke)facebook上的用户。然而,这只是我指定的特定人员。这很容易做到,因为我可以使用特定的uid显示显示戳的HTML,具体如下: document.getElementById("poke_uidhere").innerHTML; 这将生成代码/link/ajax来重新生成它们: <div class="lfloat fsm fwn fcg"><a href="https://www.face
document.getElementById("poke_uidhere").innerHTML;
这将生成代码/link/ajax来重新生成它们:
<div class="lfloat fsm fwn fcg"><a href="https://www.facebook.com/profile.php?id=uidhere">FRIEND NAME</a> · <a ajaxify="/ajax/poke_dialog.php?uid=uidhere&pokeback=1" rel="dialog-post">Poke Back</a></div><a class="rfloat uiCloseButton uiCloseButtonSmall" ajaxify="/ajax/poke_hide.php?p=uidhere" href="#" rel="async-post" title="Remove"></a>
它根本不点击。它实际上会在这里暂停,因为我在它之后添加了一个alert(),而该alert从未出现过
我放弃了这种方法,开始尝试使用:
ourUrl = "/ajax/poke_dialog.php?uid=uidhere&pokeback=1"
function httpGet(theUrl)
{
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "POST", theUrl, false );
xmlHttp.send( null );
return xmlHttp.responseText;
}
httpGet(ourUrl);
这也没用
我认为第一个想法的问题可能是HTML以某种方式重置,因为当我在脚本完成后查看源代码时,我添加的ID标记不再存在。(所以单击不起作用?:/)
我只是猜测第二种方法,所以idk为什么不起作用。为了记录在案,我尝试了GET和POST方法
我正在寻找任何和所有的解决方案
我能想到的唯一其他信息是,这是从主页上获得的(http://facebook.com)我认为在不同的页面上有不同的代码。试试这样:
var src = document.getElementById("poke_uidhere").getElementsByTagName('a')[1].src,
iframe = document.createElement('iframe');
iframe.src = src;
iframe.style.display = 'none';
document.appendChild(iframe);
您可以添加加载事件以在完成后将其删除,但我认为您不需要它不起作用。我不确定这个iframe除了创建另一个指向ajax的链接之外,还能做什么。至少它看起来是这样的,但当我运行
警报(document.getElementById(“poke_uidhere”).getElementsByTagName('a')[1].src)时,我甚至找不到iframe代码>显示为“未定义”
ourUrl = "/ajax/poke_dialog.php?uid=uidhere&pokeback=1"
function httpGet(theUrl)
{
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "POST", theUrl, false );
xmlHttp.send( null );
return xmlHttp.responseText;
}
httpGet(ourUrl);
var src = document.getElementById("poke_uidhere").getElementsByTagName('a')[1].src,
iframe = document.createElement('iframe');
iframe.src = src;
iframe.style.display = 'none';
document.appendChild(iframe);