最佳答案
这是一个很常见的问题;请参阅"Choosing and activating the right controls on an AJAX-driven site"有关如何解决此类问题的更多详细信息。
考虑到这个秘诀,唯一的艺术/技能/困难部分是选择正确的 jQuery 选择器。在这种情况下,可以通过以下方式可靠地获得“显示更多”链接:
#synopsis div.copy a.show-more-truncate
因此,完整的工作脚本将是:
// ==UserScript==
// @name _BBC episode, click "Show More" link
// @include http://www.bbc.co.uk/programmes/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.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.
*/
waitForKeyElements (
"#synopsis div.copy a.show-more-truncate", clickShowMoreLink, true
);
function clickShowMoreLink (jNode) {
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent ("click", true, true);
jNode[0].dispatchEvent (clickEvent);
}
关于javascript - 如何使用 Greasemonkey 单击 "Show More"链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16224333/