Skip to content

Instantly share code, notes, and snippets.

@june29
Created January 4, 2011 09:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save june29/764564 to your computer and use it in GitHub Desktop.
Save june29/764564 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Social count
// @namespace http://june29.jp/
// @include http://*
// @include https://*
// ==/UserScript==
(function() {
if (window.top != window.self) exit;
var body = document.body;
var title = document.title;
var url = location.href;
var area = document.createElement('div');
area.setAttribute('id', 'social-count-area');
GM_addStyle("#social-count-area { margin: 0; padding: 6px 10px 1px; height: 26px; }");
GM_addStyle("#social-count-area { text-align: left; background-color: rgba(255, 255, 255, 0.75); }");
GM_addStyle("#social-count-area * { display: inline; vertical-align: top; }");
body.insertBefore(area, body.firstChild);
var twitter = document.createElement('span');
twitter.setAttribute('id', 'social-count-twitter');
var twitter_html = '';
twitter_html += '<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>';
twitter_html += '<div><a href="http://twitter.com/share?url=';
twitter_html += encodeURIComponent(url) + '&amp;via=june29" class="twitter-share-button">Tweet</a></div>';
twitter.innerHTML = twitter_html;
setTimeout(function() { area.appendChild(twitter); }, 200);
var hatena = document.createElement('span');
hatena.setAttribute('id', 'social-count-hatena');
var hatena_html = '';
hatena_html += '<a href="http://b.hatena.ne.jp/entry/' + url + '" class="hatena-bookmark-button"';
hatena_html += ' data-hatena-bookmark-title="' + title + '" data-hatena-bookmark-layout="standard"';
hatena_html += ' title="このエントリーをはてなブックマークに追加">';
hatena_html += '<img src="http://b.st-hatena.com/images/entry-button/button-only.gif"';
hatena_html += ' alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" />';
hatena_html += '</a><script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button.js"'
hatena_html += ' charset="utf-8" async="async"></script>';
hatena.innerHTML = hatena_html;
setTimeout(function() { area.appendChild(hatena); }, 400);
var facebook = document.createElement('span');
facebook.setAttribute('id', 'social-count-facebook');
var facebook_html = '';
facebook_html += '<iframe src="http://www.facebook.com/plugins/like.php?href=';
facebook_html += encodeURIComponent(url) + '&layout=standard&show_faces=false&width=450&action=like&colorscheme=light"';
facebook_html += 'allowtransparency="true" style="border: medium none; overflow: hidden; width: 450px; height: 24px;';
facebook_html += ' margin: -2px 0 0 20px;"';
facebook_html += 'frameborder="0" scrolling="no"></iframe>';
facebook.innerHTML = facebook_html;
setTimeout(function() { area.appendChild(facebook); }, 600);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment