如何制作Greasemonkey单击指定文本的链接?

Ray*_*ayB 10 javascript greasemonkey click hyperlink

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

<a href="unlock.php?confirm=MD5hashere">Click Here</a>
Run Code Online (Sandbox Code Playgroud)

Bro*_*ams 12

这是一个启动脚本.请注意,如果您使用的是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
Run Code Online (Sandbox Code Playgroud)


也可以看看: