I'm trying to write some comment expander (as greasemonkey script) for livejournal, and get stuck with click simulating on the expand link:
<div style='margin-top: 3px; font-size: smaller'>
(<a href="http://unique page url" rel="nofollow">Reply</a>)
(<a href='page url'>Parent</a>)
(<a href='http://unique page url'>Thread</a>)
<span id='expand_*'>(<a href='http://unique page url' onclick="ExpanderEx.make(event,this,'http://unique page url','*',true)">Expand</a>)</span>
<div class="quickreply" id="ljqrt*" style="display: none;"></div>
</div>
I tried this code to activate all links on the page, but failed:
$(document).ready(function() {
$('a').each(function() {
$(this).[0].click();
});
});
Any help would be much appreciated, because I'm totally newbie with jquery.
UPD. I modify script, so it looks like this:
jQuery(document).ready(function() {
console.log("function execute");
$('[id^="expand_"] a').click();
console.log("function Log");
console.log($());
});
Console output in firebug after execution is:
function execute --- lj_expa...user.js (line 10)
TypeError: $(...) is null --- lj_expa...user.js (line 11)
Server did not return the new auth_token, further request may fail Error: Permission denied to access property 'toString' --- ??.ljli...3140103 (line 1372)
UPD. Adding the line below solved my problem, both selectors work correct!
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js