好吧,基本上我想单击一个更改但始终具有相同文本名称的链接。
以下是代码可能的示例

<a href="unlock.php?confirm=MD5hashere">Click Here</a>

最佳答案

这是一个执行该操作的入门脚本。请注意,如果您使用的是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

也可以看看:
  • 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
  • 关于javascript - 如何制作Greasemonkey单击具有特定文本的链接?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5036737/

    10-11 14:13