Skip to content

Instantly share code, notes, and snippets.

@Ajnasz
Created June 4, 2011 13:56
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 Ajnasz/1007918 to your computer and use it in GitHub Desktop.
Save Ajnasz/1007918 to your computer and use it in GitHub Desktop.
google +1 hup.hu article titles
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>A</title>
</head>
<body>
<a href="javascript:(function(){var doc=document,a=Array.prototype.slice.call(doc.querySelectorAll('h2.title a')).filter(function (a) {return a.href!==''&&a.parentNode.className!=='nnew';}),b=doc.createElement('span');a.forEach(function(l,i){var c=b.cloneNode(true),id='plusone'+i;c.id=id;a[i].parentNode.appendChild(c);gapi.plusone.render(id,{size:'small',count:true,href:l.href});});Array.prototype.slice.call(doc.querySelectorAll('.comment')).forEach(function(comment,i){var href=comment.previousSibling.previousSibling.id;if(href){var span=doc.createElement('span'),id='commentcount'+i;span.id=id;comment.querySelector('.submitted').appendChild(span);gapi.plusone.render(id,{href:doc.location.href+'#'+href,count:true,size:'small'});}});}());
">+1</a>
</body>
</html>
(function () {
var doc = document;
var a = Array.prototype.slice.call(doc.querySelectorAll('h2.title a'))
.filter(function (a) {
return a.href !== '' && a.parentNode.className !== 'nnew';
}),
b = doc.createElement('span');
a.forEach(function (l, i) {
var c = b.cloneNode(true),
id = 'plusone' + i;
c.id = id;
a[i].parentNode.appendChild(c);
gapi.plusone.render(id, {size:'small', count:true, href: l.href});
});
Array.prototype.slice.call(doc.querySelectorAll('.comment')).forEach(function (comment, i) {
var href = comment.previousSibling.previousSibling.id;
if (href) {
var span = doc.createElement('span'),
id = 'commentcount' + i;
span.id = id;
comment.querySelector('.submitted').appendChild(span);
gapi.plusone.render(id, {href: doc.location.href + '#' + href, count: true, size: 'small'});
}
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment