Skip to content

Instantly share code, notes, and snippets.

@lingkz
Last active June 20, 2018 02:10
Show Gist options
  • Save lingkz/c82ea32c715b0f409f84 to your computer and use it in GitHub Desktop.
Save lingkz/c82ea32c715b0f409f84 to your computer and use it in GitHub Desktop.
surfingkeys
// an example to create a new mapping `ctrl-y`
mapkey('<Ctrl-y>', 'Show me the money', function() {
Normal.showPopup('a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close).');
});
// an example to replace `u` with `?`, click `Default mappings` to see how `u` works.
map('?', 'u');
// an example to remove mapkey `Ctrl-i`
unmap('<Ctrl-i>');
// click `Save` button to make above settings to take effect.
// weibo
mapkey('zz', '收起', "clickOn($('a').regex(/tosmall/i, $.fn.attr, ['action-type']))", 0, /weibo.com/i);
mapkey('q', '点开微博上的图片/视频', 'Hints.create("div.media_box img", Hints.dispatchMouseClick)', 0, /weibo.com/i);
// 网易云音乐
mapkey(']]', '下一首', 'clickOn("li.fm-next a")', 0, /fm.baidu.com/i);
mapkey('[[', '上一首', 'clickOn("div.pre-img-wrapper p")', 0, /fm.baidu.com/i);
// map keys
map('J', 'E');
map('K', 'R');
map('H', 'S');
map('L', 'D');
mapkey('[[', 'Click on the previous link on current page', function() {
var prevLinks = $('a').regex(/((上页|上一页|<<|prev(ious)?)+)/i);
if (prevLinks.length) {
clickOn(prevLinks);
} else {
walkPageUrl(-1);
}
});
mapkey(']]', 'Click on the next link on current page', function() {
var nextLinks = $('a').regex(/((下页|下一页|>>|next)+)/i);
if (nextLinks.length) {
clickOn(nextLinks);
} else {
walkPageUrl(1);
}
});
// searchEngine
addSearchAliasX('yk', 'youku', 'http://www.soku.com/search_video/q_', 'o');
addSearchAliasX('wkz', 'wikipedia_zh', 'https://zh.wikipedia.org/w/index.php?search=', 'o');
addSearchAliasX('wke', 'wikipedia_en', 'https://en.wikipedia.org/w/index.php?search=', 'o');
addSearchAliasX('j', 'jd search', 'http://search.jd.com/Search?enc=utf-8&keyword=', 'o');
//addSearchAliasX('tb', 'taobao', 'https://s.taobao.com/search?q=', 'o');
addSearchAliasX('zh', 'zhihu search', 'https://www.zhihu.com/search?type=question&q=');
// 淘宝搜索
addSearchAliasX('tb', 'taobao', 'https://s.taobao.com/search?q=', 's', 'https://suggest.taobao.com/sug?code=utf-8&q=', function(response) {
var res = eval("a=" + response.text);
res = res.result.map(function(r) {
return r[0];
});
Omnibar.listWords(res);
});
// 优酷搜索
addSearchAliasX('yk', 'youku', 'http://www.soku.com/search_video/q_', 's', 'http://tip.soku.com/search_tip_1?query=', function(response) {
var res = eval("a=" + response.text);
res = res.r.map(function(r) {
return r.w;
});
Omnibar.listWords(res);
});
mapkey('Oyk', '#13Open Search with alias yk', 'Normal.openOmnibar({type: "SearchEngine", extra: "yk"})');
mapkey('Owz', '#13Open Search with alias wkz', 'Normal.openOmnibar({type: "SearchEngine", extra: "wkz"})');
mapkey('Owe', '#13Open Search with alias wke', 'Normal.openOmnibar({type: "SearchEngine", extra: "wke"})');
mapkey('Otb', '#13Open Search with alias tb', 'Normal.openOmnibar({type: "SearchEngine", extra: "tb"})');
mapkey('Ozh', '#13Open Search with alias z', 'Normal.openOmnibar({type: "SearchEngine", extra: "zh"})');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment