Last active
May 19, 2017 16:15
-
-
Save dsdshcym/29a32622e2df546b1836ead08a890190 to your computer and use it in GitHub Desktop.
Config file for Chrome Extension SurfingKey
This file contains 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
settings.smoothScroll = false; | |
map('<Ctrl-d>', 'd'); | |
map('<Ctrl-u>', 'e'); | |
map('gm', '<Ctrl-h>'); | |
map('gM', '<Ctrl-j>'); | |
map('F', 'gf'); | |
map('b', 'T'); | |
map('q', 'x'); | |
map('u', 'X'); | |
map('p', 'sg'); | |
map('P', 'cc'); | |
map('R', 'ox'); | |
map('a', 'og'); | |
map('<Ctrl-o>', 'S'); | |
map('<Ctrl-i>', 'D'); | |
mapkey('oc', '', function() { | |
orgCapture(); | |
}) | |
mapkey('ok', '', function() { | |
orgCapture('k'); | |
pushToKindle(); | |
}) | |
function orgCapture(template) { | |
var url = encodeURIComponent(currentUrl()); | |
var title = encodeURIComponent(parsePipeChar(currentTitle())); | |
var body = encodeURIComponent(window.getSelection()); | |
var base = 'org-protocol://capture'; | |
var params = [['url', url], ['title', title], ['body', body], ['template', template]]; | |
window.location.href = buildGetLink(base, params); | |
} | |
function pushToKindle() { | |
var base = "http://fivefilters.org/kindle-it/send.php" | |
var params = [['url', encodeURIComponent(currentUrl())]]; | |
tabOpenLink(buildGetLink(base, params)); | |
} | |
function currentUrl() { | |
return window.location.href; | |
} | |
function currentTitle() { | |
return document.title; | |
} | |
function parsePipeChar(string) { | |
return string.replace(/\|/g, '-'); | |
} | |
function buildGetLink(base, params) { | |
return base + | |
'?' + | |
params.map(buildParamFromKeyValuePair).join('&'); | |
} | |
function buildParamFromKeyValuePair(key_value) { | |
var key = key_value[0]; | |
var value = key_value[1]; | |
return value ? key + '=' + value : ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment