需要使用油脂猴脚本点击出价按钮
我有点卡住了。我正在尝试创建一个油脂猴脚本,该脚本将自动单击拍卖网站上出现的弹出窗口。我有 Xpat,但我对 GM 的经验太丰富,无法让它发挥作用。
这是我从 firebug 的 fire finder 获得的元素检查行:
<input type="submit" style="width: 160px;" class="simplemodal-close" id="ctl00_mainContentPlaceholder_Button3" onclick="closePopup(); return false;" value="Back To Auctions" name="ctl00$mainContentPlaceholder$Button3">
并且 firpath、xpath 行是:
.//*[@id='ctl00_mainContentPlaceholder_Button3']
完整 xpath 的 xpather 行:
/html/body/form[@id='aspnetForm']/div[@id='simplemodal-container']/div/div[@id='basic-modal-content']/div[@id='modal_winningBanner']/div/div[2]/div[2]/input[@id='ctl00_mainContentPlaceholder_Button3']
所以我在 gm 脚本中使用的尝试让它单击按钮的内容如下:
// @include *
// @version 0.1
// @description Automatically click // ==/UserScript==
click_popupBtn1 = function() {
var joinBtn=document.evaluate('//*[@id, "ctl00_mainContentPlaceholder_Button3"]'
,document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null).singleNodeValue.click();
alert(joinBtn);
if(!joinBtn) return false;
joinBtn.click();
return true;
}
click_popupBtn1 ();
我认为我的语法有问题,但不知道如何调试 GM。我几年前才使用过 Turbo Pascal,但想用 Java 和 GM 完成一些简单的事情。
任何帮助将不胜感激。
谢谢 路德维希
I'm a bit stuck. I'm trying to create an Grease Monkey script that will automatically click an pop-up that appears on an auction site. I'v got the Xpat, but i'm too in expierienced with GM to get it to work.
Here is theelement inspection line i get from fire finder for firebug:
<input type="submit" style="width: 160px;" class="simplemodal-close" id="ctl00_mainContentPlaceholder_Button3" onclick="closePopup(); return false;" value="Back To Auctions" name="ctl00$mainContentPlaceholder$Button3">
and the firpath, xpath line is:
.//*[@id='ctl00_mainContentPlaceholder_Button3']
xpather line for full xpath:
/html/body/form[@id='aspnetForm']/div[@id='simplemodal-container']/div/div[@id='basic-modal-content']/div[@id='modal_winningBanner']/div/div[2]/div[2]/input[@id='ctl00_mainContentPlaceholder_Button3']
So what i used in my gm script to try to get it to click the button is as follows:
// @include *
// @version 0.1
// @description Automatically click // ==/UserScript==
click_popupBtn1 = function() {
var joinBtn=document.evaluate('//*[@id, "ctl00_mainContentPlaceholder_Button3"]'
,document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null).singleNodeValue.click();
alert(joinBtn);
if(!joinBtn) return false;
joinBtn.click();
return true;
}
click_popupBtn1 ();
I think ive got something wrong on the syntax, but dont know how to debug GM. I've only worked with turbo pascal a few years ago, but would like to get some simple things done in java and GM.
Any help would be apreciated.
Thanks
Ludwig
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,我不明白你使用的很多单词或这种复杂的语法。
但类似:
应该有效。
umm, I don't understand a lot of the words you used or this complex syntax.
but something like:
should work.
上面的第一个参数不是语法上合法的 XPath 表达式。
应该是:
The first argument above is not a syntactically legal XPath expression.
Should be: