Skip to content

Instantly share code, notes, and snippets.

@laiso
Created December 6, 2011 08:22
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 laiso/1437347 to your computer and use it in GitHub Desktop.
Save laiso/1437347 to your computer and use it in GitHub Desktop.
###
* @title Google 検索の結果にtwitter上で何個言及されているかを表示するブックマークレット
* @description http://d.hatena.ne.jp/laiso/20111204/p1
* @include http://*.google.*\/search
* @licence MIT
* @require jQuery
###
_STYLE = """
padding: 0 0.5em;
margin: 0 0.5em;
color: #30566D;
text-shadow: 0 1px 0 white;
background-color: #C0DEED;
font-weight: bold;
text-decoration-line: none;
"""
addCounter = (a) ->
jQuery.getJSON 'http://urls.api.twitter.com/1/urls/count.json?url='+encodeURIComponent(a.href)+'&callback=?'
,null
, (data, textStatus, jqXHR) =>
counter = document.createElement 'A'
counter.setAttribute('style', _STYLE)
counter.href = 'https://twitter.com/#!/search/realtime/' + encodeURIComponent a.href
counter.innerText = data['count']
point = document.createRange()
point.selectNode(a)
point.collapse false
point.insertNode counter
point.detach()
links = document.querySelectorAll 'a.l'
for all, a of links
if typeof a == 'object'
addCounter a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment