如何使Greasemonkey单击一个指定文本的链接? [英] How do you make Greasemonkey Click a link that has specified text?
本文介绍了如何使Greasemonkey单击一个指定文本的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好吧,基本上我想点击一个链接更改,但总是有相同的文本名称。
下面是代码可能的示例
Alright basically i want to click a link that changes but always has the same text name. Heres an example of what the code might be
<a href="unlock.php?confirm=MD5hashere">Click Here</a>
推荐答案
请注意,它使用jQuery,并假设您正在运行Firefox或使用Tampermonkey(如果您使用Chrome)。
Here is a starter script that does that. Note that it uses jQuery and assumes you are running Firefox or using Tampermonkey, if you are on Chrome.
// ==UserScript==
// @name _YOUR_SCRIPT_NAME
// @include http://YOUR_SERVER.COM/YOUR_PATH/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.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.
*/
//--- Note that the contains() text is case-sensitive.
var TargetLink = $("a:contains('Click Here')")
if (TargetLink.length)
window.location.href = TargetLink[0].href
另请参阅:
See also:
- Adding keylistener and using javascript to click a link in Greasemonkey
- "Normal" button-clicking approaches are not working in Greasemonkey script?
- Choosing and activating the right controls on an AJAX-driven site
这篇关于如何使Greasemonkey单击一个指定文本的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文