// ==UserScript== // @name Twitter Search Plus // @namespace intridea // @description Find replies to a tweet in the Twitter Search timeline with the click of a button. // @include http://search.twitter.com/search* // ==/UserScript== // Add jQuery var GM_JQ = document.createElement('script'); GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; GM_JQ.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(GM_JQ); // Check if jQuery's loaded function GM_wait() { if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); } else { jQuery = unsafeWindow.jQuery; jQuery.noConflict(); letsJQuery(); } } GM_wait(); // All your GM code must be inside this function function letsJQuery() { jQuery('li.result div.info').append('ยท Thread Find Replies'); jQuery('li.result').append(''); jQuery('a.find-replies').each(function() { var result = jQuery(this).parents('li.result'); var user_name = result.find('div.msg a:first').text(); var since_array = result.find('div.info a.lit').attr('href').split('/'); var since_id = since_array[since_array.length - 1]; jQuery(this).attr('href','http://search.twitter.com/search?q=to:' + user_name + '&since_id=' + since_id); }).click(function() { link = jQuery(this); var search_url = link.attr('href').replace("/search?q","/search.json?q") + '&rpp=15&show_user=true'; jQuery.ajax({ url: search_url, dataType: 'json', beforeSend:function() { link.html('Loading Replies...'); }, success:function(data) { if (data.results.length == 0) { link.html('No Replies Found'); } var html = ""; link.parents('li.result').find('div.reply-finder-results').html(html).slideToggle(500,function() { if (link.parents('li.result').find('div.reply-finder-results').is(':visible')) link.html('Hide Replies'); else link.html('Find Replies'); }); } }); return false; }); autolink = function(text) { text = text.replace(/(https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?)/g, "$1"); text = text.replace(/(^|\W)?@([a-zA-Z0-9]+)(\W|$)/g, "$1@$2$3"); return text; } linkify = function(text, url) { return "" + text + ""; } }