Skip to content

Instantly share code, notes, and snippets.

@ebith
Last active August 29, 2015 14: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 ebith/a2d1a6bf07dfc040c582 to your computer and use it in GitHub Desktop.
Save ebith/a2d1a6bf07dfc040c582 to your computer and use it in GitHub Desktop.
(function() {
var sites, _ref;
sites = ((_ref = liberator.globalVariables.yaopen) != null ? _ref.sites : void 0) || {
tts: {
url: 'http://translate.google.com/translate_tts?tl=en&q=%ARG%'
},
steamdb: {
url: 'https://steamdb.info/search/?a=app&q=%ARG%'
},
pcgamingwiki: {
icon: 'http://pcgamingwiki.com/images/WikiFavicon.png',
url: 'http://pcgamingwiki.com/w/index.php?search=%ARG%'
},
'2ch': {
url: 'http://find.2ch.net/search?q=%ARG%'
},
isthereanydeal: {
icon: 'http://s3-eu-west-1.amazonaws.com/itad/images/favicon.png',
url: 'http://isthereanydeal.com/#/search:%ARG%;/scroll:#gamelist'
},
devdocs: {
description: 'API Document Browser',
url: 'http://devdocs.io/#q=%ARG%'
},
mdn: {
description: 'Mozilla Developer Network',
icon: 'http://developer.cdn.mozilla.net/media/redesign/img/favicon32.png',
url: 'https://www.google.com/search?q=site:developer.mozilla.org/ja/docs %ARG%'
},
wikipedia: {
url: 'http://ja.wikipedia.org/wiki/Special:Search?search=%ARG%'
},
twitter: {
url: 'https://twitter.com/search?q=%ARG%&src=typd&f=realtime'
},
'twitter(lang:ja)': {
url: 'https://twitter.com/search?q=%ARG% lang:ja&src=typd&f=realtime'
},
nicovideo: {
description: 'ニコニコ動画',
url: 'http://www.nicovideo.jp/search/%ARG%'
}
};
commands.addUserCommand(['yaopen'], 'Yet another :tabopen', function(args) {
var url;
if (sites[args[0]]) {
url = sites[args[0]].url.replace(/%ARG%/, encodeURIComponent(args[1]));
return liberator.open(url, liberator.NEW_TAB);
} else {
return liberator.echoerr("yaopen: " + args[0] + " is undefined");
}
}, {
literal: 1,
completer: function(context, args) {
var key, site;
if (args.completeArg === 1) {
return;
}
context.completions = (function() {
var _ref1, _ref2, _results;
_results = [];
for (key in sites) {
site = sites[key];
_results.push([key, (_ref1 = site.description) != null ? _ref1 : '', (_ref2 = site.icon) != null ? _ref2 : util.createURI(site.url).prePath + '/favicon.ico']);
}
return _results;
})();
context.keys = {
text: 0,
description: 1,
icon: function(item) {
return item[2] || DEFAULT_FAVICON;
}
};
return context.compare = CompletionContext.Sort.unsorted;
}
}, true);
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment