使用 Tampermonkey 出现在页面上后等待单击按钮
Wait to click a button after appearing on the page with Tampermonkey
网页上有一个我想自动点击的按钮。问题是它只在单击另一个按钮后才会出现在页面上。我已经成功地自动执行了第一次点击,但我无法在该按钮出现后自动执行第二次点击。
按钮出现后,当我在控制台中 运行 时,以下代码有效:
// ==UserScript==
// @name Soundplate SUBMIT MUSIC Button
// @include https://play.soundplate.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @grant GM_addStyle
// ==/UserScript==
var TargetLink = $("a:contains('SUBMIT MUSIC')")
if (TargetLink.length)
window.location.href = TargetLink[0].href
但我不太确定如何运行它在第一次点击发生后。
我听说过 waitForKeyElements,但我不确定如何在此处实现它。这可能是解决方案。任何和所有建议将不胜感激。
// ==UserScript==
// @name Soundplate SUBMIT MUSIC Button
// @include https://play.soundplate.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// ==/UserScript==
waitForKeyElements (
".btn-lg", click
);
function click (TargetLink) {
TargetLink = $("a:contains('SUBMIT MUSIC')")
if (TargetLink.length)
window.location.href = TargetLink[0].href
}
网页上有一个我想自动点击的按钮。问题是它只在单击另一个按钮后才会出现在页面上。我已经成功地自动执行了第一次点击,但我无法在该按钮出现后自动执行第二次点击。
按钮出现后,当我在控制台中 运行 时,以下代码有效:
// ==UserScript==
// @name Soundplate SUBMIT MUSIC Button
// @include https://play.soundplate.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @grant GM_addStyle
// ==/UserScript==
var TargetLink = $("a:contains('SUBMIT MUSIC')")
if (TargetLink.length)
window.location.href = TargetLink[0].href
但我不太确定如何运行它在第一次点击发生后。
我听说过 waitForKeyElements,但我不确定如何在此处实现它。这可能是解决方案。任何和所有建议将不胜感激。
// ==UserScript==
// @name Soundplate SUBMIT MUSIC Button
// @include https://play.soundplate.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// ==/UserScript==
waitForKeyElements (
".btn-lg", click
);
function click (TargetLink) {
TargetLink = $("a:contains('SUBMIT MUSIC')")
if (TargetLink.length)
window.location.href = TargetLink[0].href
}