Skip to content

Instantly share code, notes, and snippets.

@satyr
Created November 14, 2008 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save satyr/25094 to your computer and use it in GitHub Desktop.
Save satyr/25094 to your computer and use it in GitHub Desktop.
+function(pq, list){
const Yats = 'http://pcod.no-ip.org/yats/';
CmdUtils.CreateCommand({
name: "yats",
icon: 'http://twitter.com/favicon.ico',
takes: {'search formula': noun_arb_text},
modifiers: {'in': noun_type_language},
description: 'yet another twitter search'.link(Yats),
execute: function(inp, mod){ Utils.openUrlInBrowser(makeQ(inp, mod)) },
preview: function(pbl, inp, mod){
var q = makeQ(inp, mod);
if(!q){ pbl.innerHTML = Logo; return }
if(pq === q){ pbl.innerHTML = list; return }
pbl.innerHTML = Loading + Logo;
Utils.parseRemoteDocument(
pq = q, null,
function(doc){
var y = jQuery('<div class="yats">').append(Style)
.append(
jQuery('div.results', doc)
.find('a[href^="."]').each(
function(){ this.href = this.href }).end()
.find('div.user-image a').each(
function(k){
jQuery(this).attr('accesskey', k = (k + 1).toString(36))
.append('<kbd class="access">'+ k +'</kbd>') }).end())
.append(Logo);
pbl.innerHTML = list = jQuery('<div>').append(y).html() },
function(){ pbl.innerHTML = <i>AjaxError</i> + Logo });
},
author: 'satyr'.link('http://d.hatena.ne.jp/murky-satyr'), license: 'MIT',
});
function makeQ(i, m, t) (t = jQuery.trim(i.text)) &&
[Yats, 'search?query=', encodeURIComponent(t),
'&lang=', m.in.data || ''].join('');
const
Logo = ''+<div class="logo"><style><![CDATA[
.logo { clear: both; background: #333;
width: 160px; text-align: center }
.logo h1 a { color: #fff !important; text-decoration: none }
]]></style><h1><a href={Yats}>twitter&#x691c;&#x7D22;</a></h1></div>,
Loading = ''+<p class="loading"><i>...</i></p>,
Style = <style><![CDATA[
.yats img { width: 24px; height: 24px; border: none }
.yats li, .yats li div { float: left }
.yats ol { padding: 0 }
.yats li { clear: left; width: 100%; padding: 0 0 4px 0; font-size: 76% }
.yats li div { padding-right: 2px }
.yats h2, .yats p { clear: left; font-size: 84% }
.yats kbd.access { text-decoration: underline; vertical-align: top }
.pagination { display: none }
]]></style>.toXMLString();
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment