Skip to content

Instantly share code, notes, and snippets.

@mehdimehdi
Created April 14, 2011 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehdimehdi/920836 to your computer and use it in GitHub Desktop.
Save mehdimehdi/920836 to your computer and use it in GitHub Desktop.
How to get the latest comment.
var commentURL;
var links = document.getElementsByTagName("link");
for (var i=0; i < links.length; i++) {
var href = links[i].href;
//look for the comment feed
if (href.match(/^http:\/\/\w+.blogspot.com\/feeds\/\d+\/comments\/default$/)) {
commentURL = href;
break;
}
}
//if the commentURL was found
if (commentURL) {
//go an get the last comment
var i=document.createElement("script");
i.src=unescape(commentURL+"?alt=json-in-script&callback=onBlogSpotComment&max-results=1");
i.async=true;
i.charset="UTF-8";
document.getElementsByTagName("head")[0].appendChild(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment