Skip to content

Instantly share code, notes, and snippets.

@e-jigsaw
Forked from june29/socialcount.user.js
Created January 11, 2011 18:59
Show Gist options
  • Save e-jigsaw/774925 to your computer and use it in GitHub Desktop.
Save e-jigsaw/774925 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Social count(jigsaw tune)
// @namespace http://about.me/jigsaw
// @include http://*
// ==/UserScript==
(function() {
if (window.top != window.self) exit;
var body = document.body;
var title = document.title;
var url = location.href;
var h = window.innerHeight - 26;
var area = document.createElement('div');
area.setAttribute('id', 'social-count-area');
GM_addStyle("#social-count-area { padding: 6px 10px 1px; height: 26px; width:"+window.innerWidth+"px; }");
GM_addStyle("#social-count-area { text-align: left; background-color: rgba(255, 255, 255, 0.75); }");
GM_addStyle("#social-count-area { position: fixed; z-index: 100; top:"+h+"px; }");
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 += '<span><a href="http://twitter.com/share?url=';
twitter_html += encodeURIComponent(url) + '" class="twitter-share-button">Tweet</a></span>';
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