[英]How do you make Greasemonkey Click a link that has specified text?
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>
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.
请注意,如果您使用的是Chrome,它会使用jQuery并假设您正在运行Firefox或使用Tampermonkey。
// ==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: 也可以看看:
使用 XPath 的 Vanilla JS 版本:
document.evaluate("//a[text()='Click Here']", document).iterateNext().click()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.