2013-04-25 36 views

回答

2

这是一个非常普遍的问题;有关如何解决此类事情的更多详细信息,请参见"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); 
} 
+0

布洛克,这是完美的。感谢所有的细节。爱你的waitForKeyElements。 – 2013-04-25 22:48:28

+0

不客气;乐意效劳。 – 2013-04-25 23:51:26

+0

这个问题的答案是解决了我的问题。我不明白这是如何模糊的,等等。:-) – 2013-04-29 02:19:04