// ==UserScript== // @name Twitter Search Results on Google // @namespace http://efcl.info/ // @description Shows results from Twitter on Google search pages // @include http://www.google.*/search?*q=* // @include http://www.google.*/* // @date 2009-08-26 // @version 1.0 // ==/UserScript== // original Twitter Search Results on Google for Greasemonkey [ http://userscripts.org/scripts/show/43451 ] //表示件数 var SEARCHLIMIT = 5; GM_TUR = { un : "", lang : "ja", init : function(){ var href = document.location.href; GM_TUR.un = href.match(/[&?]q=([^&]*)(?:&|$)/)[1]; GM_TUR.lang = (href.match(/[&?]hl=([^&]*)(?:&|$)/)) ? href.match(/[&?]hl=([^&]*)(?:&|$)/)[1] : 'ja'; if( GM_TUR.un != "" ) { GM_xmlhttpRequest({ method:"GET", url:"http://pcod.no-ip.org/yats/search?query="+GM_TUR.un+"&json", headers:{ "User-Agent":"Mozilla/5.0", "Accept":"text/json" }, onload:GM_TUR.handle }); } }, handle : function(response) { //console.log(response); var r = eval("("+response.responseText+")"); if( r && r.length > 0 ) { var results = document.getElementById("res"); var ds = document.createElement("ol"); results.insertBefore(ds, results.firstChild); var il, h; var query = decodeURIComponent(GM_TUR.un).replace(/\+/g, ' '); h = ds.appendChild(document.createElement("li")); h.className = "g"; var h3 = h.appendChild(document.createElement("h3")); h3.className = "r"; h3.innerHTML = "Twitter results for "+ query +""; var t = h.appendChild(document.createElement("table")); t.className = "ts"; var tb = t.appendChild(document.createElement("tbody")); var row = tb.appendChild(document.createElement("tr")); row.innerHTML = ''; if(r.length < SEARCHLIMIT){ SEARCHLIMIT = r.length; } var li = ""; for( var i=0; i < SEARCHLIMIT; i++ ) { il = "
" + "" + r[i].user+": " + r[i].content +' '+r[i].time+'
'; li = li + il; } row.innerHTML += li + ''; } }, }; GM_TUR.init();