Playing With Bookmarklets
Every so often I’ve found myself wanting to link to a specific comment over on LitReactor. Unfortunately, while they have in page anchors, there is no easy way to get at a link to them. Having fought with developer tools tracking down the right anchor element one too many times, I decided to throw this little toy together right quick:
javascript:(function () { var comment_container = $('#comments'); var comments = $('div.comment', comment_container); var anchors = $('a[id~=comment]', comment_container); for (var i = 0; i < anchors.length; i++) { var anchor = $(anchors[i]); var comment = $(comments[i]); var href = window.location.href + '#' + anchor.attr('id'); $('.comment-content .comment-meta a:first-child ', comment).before( '<a href="' + href + '"> # </a>' ); } })();
And here it is as a link:
Keep in mind, this is just a toy! No warranties, use at your own risk etc!
Programming
Leave a Reply