Last active
November 21, 2018 11:37
-
-
Save 958/9f4d93e8308920478159566008c56f8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hints.characters = 'asdfgwertzxcvb'; | |
settings.hintAlign = 'left'; | |
settings.nextLinkRegex = /((?!first)(next|older|more|>|›|»|forward|→|次(のページ|へ))+)/i; | |
settings.prevLinkRegex = /((?!last)(prev(ious)?|newer|back|«|less|<|‹|←|前(のページ|へ))+)/i; | |
settings.focusAfterClosed = 'right'; | |
settings.scrollStepSize = 70; | |
settings.smoothScroll = true; | |
[ | |
'cp', ';cp', ';ap', ';s', 'spa', 'spb', 'spd', 'sps', 'spc', 'sd', | |
'gr', 'gr', 'gf', 'af', 'sfr', 'C', 'yc', 'yq', 'B', 'F', 'Q', | |
'<Ctrl-6>', 'S', 'D', 'W', 'cc', 'ys', 'yj', 'yd', 'yf', 'yp', 'yl', | |
'gs', 'g?', 'gxt', 'gxT', 'gx0', 'gx$', 'ZZ', 'ZR', | |
'ox', 'ob', 'ow', ';t', 'sw', 'sb', 'ss', | |
'sm', '<Ctrl-i>', 'I', '<Ctrl-Alt-d>', 'su', ';m', ';j', ';pp', ';q', ';dh', ';db', | |
].forEach(k => unmap(k)); | |
[ 'gr', '<Ctrl-d>', '<Ctrl-u>' ].forEach(k => vunmap(k)); | |
map('<Ctrl-[>', '<Esc>'); | |
cmap('<Ctrl-[>', '<Esc>'); | |
imap('<Ctrl-[>', '<Esc>'); | |
vmap('<Ctrl-[>', '<Esc>'); | |
mapkey('T', 'Choose a tab with omnibar', () => | |
Front.openOmnibar({type: "Tabs"}) | |
); | |
mapkey('f', '#1Open a link', () => Hints.create('', Hints.dispatchMouseClick)); | |
mapkey('F', '#1Open a link in non-active new tab', () => | |
Hints.create('', Hints.dispatchMouseClick, {tabbed: true, active: false})); | |
mapkey('ya', '#7Copy a link URL to the clipboard', () => Hints.create('*[href]', e => Clipboard.write(e.href))); | |
mapkey('yma', '#7Copy multiple link URLs to the clipboard', () => { | |
var linksToYank = []; | |
Hints.create('*[href]', (e) => | |
linksToYank.push(e.href) && Clipboard.write(linksToYank.join('\n')), | |
{multipleHits: true}); | |
}); | |
mapkey('i', '#1Go to edit box', () => { | |
Hints.create("input:visible, textarea:visible, *[contenteditable=true], select:visible", e => | |
(e.tagName === 'SELECT') ? Front.showEditor(e) : Hints.dispatchMouseClick(e)); | |
}); | |
mapkey(';l', 'Add a link URL to pocket', () => | |
Hints.create('*[href]', (e) => | |
httpRequest( | |
{'url': `https://getpocket.com/edit?url=${encodeURIComponent(e.href)}`}, | |
res => Front.showBanner('Success') | |
) | |
)); | |
mapkey('<Ctrl-l>', 'Add a current URL to pocket', () => | |
httpRequest( | |
{'url': `https://getpocket.com/edit?url=${encodeURIComponent(window.location.href)}`}, | |
res => Front.showBanner('Success') | |
)); | |
mapkey(';b', 'Open a link URL with Hatena Bookmark', () => | |
Hints.create('*[href]', e => tabOpenLink(`http://b.hatena.ne.jp/entry?url=${encodeURIComponent(e.href)}`))); | |
mapkey('<Ctrl-b>', 'Open a current URL with Hatena Bookmark', () => | |
tabOpenLink(`http://b.hatena.ne.jp/entry?url=${encodeURIComponent(window.location.href)}`)); | |
mapkey('^', '#4Go to last used tab', () => RUNTIME('goToLastTab')); | |
mapkey('H', '#4Go back in history', () => history.go(-1), {repeatIgnore: true}); | |
mapkey('L', '#4Go forward in history', () => history.go(1), {repeatIgnore: true}); | |
mapkey('gX', '#8Open recently closed URL', () => Front.openOmnibar({type: 'URLs', extra: 'getRecentlyClosed'})); | |
const setTranslateQuery = (lang) => { | |
const render = (res) => res[0].map(r => r[0]).join(''); | |
Front.registerInlineQuery({ | |
url: `https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=${lang}&dt=t&dt=bd&q=`, | |
parseResult: res => [ render(JSON.parse(res.text)) ], | |
}); | |
}; | |
setTranslateQuery('ja'); | |
mapkey('J', '#8Open omnibar for word translation (to Ja)', () => { | |
Front.openOmniquery({ query: Visual.getWordUnderCursor(), style: 'opacity: 0.8;' }); | |
}); | |
mapkey('K', '#8Open omnibar for word translation (to En)', () => { | |
setTranslateQuery('en'); | |
Front.openOmniquery({ query: Visual.getWordUnderCursor(), style: 'opacity: 0.8;' }); | |
setTranslateQuery('ja'); | |
}); | |
mapkey("<Ctrl-'>", '#10Jump to vim-like mark', Normal.jumpVIMark); | |
mapkey("'", '#10Jump to vim-like mark in new tab.', (mark) => Normal.jumpVIMark(mark, true)); | |
map('`', "'"); | |
mapkey('yy', "#7Copy current page's URL", () => Clipboard.write(window.location.href)); | |
mapkey('yt', "#7Copy current page's title", () => Clipboard.write(document.title)); | |
mapkey(';e', 'Translate selected text with google', () => | |
searchSelectedWith('https://translate.google.com/?hl=en#auto/en/', false, false, '')); | |
mapkey(';j', 'Translate selected text with google', () => | |
searchSelectedWith('https://translate.google.com/?hl=en#auto/ja/', false, false, '')); | |
addSearchAliasX('b', 'bing', 'http://global.bing.com/search?setmkt=en-us&setlang=en-us&q=', 's', 'http://api.bing.com/osjson.aspx?query=', | |
(res) => JSON.parse(res.text)[1]); | |
addSearchAliasX('h', 'github', 'https://github.com/search?type=Code&utf8=%E2%9C%93&q='); | |
if (/feedly\.com/.test(window.location.hostname)) { | |
['j', 'k', 'y', 'v', 's', 'g', 'a', 'l', '?'].forEach(k => unmap(k)); | |
mapkey('a', 'Open a current entry in new tab', () => { | |
const e = document.querySelector('div.entryHeader a'); | |
if (e) { | |
RUNTIME("openLink", { | |
tab: { tabbed: true, active: false }, | |
url: e.href | |
}); | |
} | |
}); | |
mapkey('l', 'Add a current entry to pocket', () => { | |
const e = document.querySelector('div.entryHeader a'); | |
if (e) { | |
httpRequest( | |
{'url': `https://getpocket.com/edit?url=${encodeURIComponent(window.location.href)}`}, | |
res => Front.showBanner('Success') | |
); | |
} | |
}); | |
} | |
if (/(inbox|gmail)\.google.com/.test(window.location.hostname)) { | |
['j', 'k', 'e', '#', 'o', 'u', 'O', 'n', 'p', 't', 'i', 'r', 'f', 'z', '?'].forEach(k => unmap(k)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment