[英]Button click help (Greasemonkey)
Please help me, I need to click these 2
buttons
links: 请帮助我,我需要单击以下2个
按钮
链接:
<li class="booster" id="b_10">
<img alt="" src="http://www.erepublik.com/images/parts/pixel.gif" class="overlay" />
<div class="top">
<strong><a href="javascript:;">Army boots</a></strong>
<big>0</big>
</div>
<img src="http://static.erepublik.com/uploads/boosters/10_77x77.png" alt="" />
<em class="give like10"></em>
</li>
And: 和:
<span class="tip" id="tip_534689">
<a class="workTrigger" companyId="534689" href="javascript:;">
<img src="http://www.erepublik.com/images/modules/myland/tip_icons/work.png" alt="" />
</a>
</span>
Something like this should work, but the // @include
directive should be more specific, if possible, and the jQuery selectors might require information that was not given in the question. 这样的事情应该可以工作,但是
// @include
指令应该更具体(如果可能的话),并且jQuery选择器可能需要问题中未提供的信息。
The art is in choosing the selectors to get the link/button/node you are after. 技巧是选择选择器以获取您想要的链接/按钮/节点。 For best results, this often requires seeing the whole page's code.
为了获得最佳结果,这通常需要查看整个页面的代码。
// ==UserScript==
// @name _Generic Link clicker
// @include http://www.erepublik.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js
// ==/UserScript==
var topBoosterLink = $("li.booster > div.top > strong > a:first");
var workTipLink = $("span.tip > a.workTrigger:first");
clickJ_Node (topBoosterLink);
clickJ_Node (workTipLink);
function clickJ_Node (jNode)
{
if (jNode && jNode.length)
{
var clickEvent = document.createEvent ("HTMLEvents");
clickEvent.initEvent ("click", true, true);
jNode[0].dispatchEvent (clickEvent);
}
else
GM_log ('No node found to click!');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.