Created
April 14, 2011 23:37
-
-
Save mehdimehdi/920836 to your computer and use it in GitHub Desktop.
How to get the latest comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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