Last active
January 29, 2022 19:50
-
-
Save amiroslaw/511d743ff763869ffafa44d2477a4b31 to your computer and use it in GitHub Desktop.
surfingkeys config
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
const { | |
aceVimMap, | |
mapkey, | |
unmap, | |
imap, | |
imapkey, | |
getClickableElements, | |
vmapkey, | |
map, | |
cmap, | |
addSearchAlias, | |
removeSearchAlias, | |
tabOpenLink, | |
readText, | |
Clipboard, | |
Front, | |
Hints, | |
Visual, | |
RUNTIME | |
} = api; | |
map(">_l", "l"); | |
map("l", "R"); | |
map(">_h", "h"); | |
map("h", "E"); | |
map(";;", "x"); | |
map(">_l", ">_l"); | |
map(">_h", ">_h"); | |
map("H", "B"); | |
map("af", "cf"); | |
map("L", ">_F"); | |
//swap mapping | |
//unmap("f"); | |
map('tempf', 'f'); | |
map("f", "gf"); | |
map("F", "tempf"); | |
// google fix | |
settings.hintAlign = "left" | |
addSearchAliasX('c', 'ceneo', 'https://www.ceneo.pl/;szukaj-'); | |
//addSearchAliasX('p', 'diki', 'https://allegro.pl/listing?string=%s&order=m&bmatch=base-relevance-floki-5-nga-cul-1-4-0614', 'o'); | |
addSearchAliasX('p', 'diki', 'https://www.diki.pl/slownik-angielskiego?q='); | |
mapkey(';t', 'Translate selected text with google', function() { | |
searchSelectedWith('https://translate.google.com/?hl=en#en/pl/', false, false, ''); | |
}); | |
// mapkey('ci', '#2Download Image', function() { Hints.create('img', function(element) { chrome.downloads.download({url: element.src}); }); }); | |
//mapkey('<Ctrl-y>', 'Show me the money', function() { | |
// Front.showPopup('a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close).'); | |
//}); | |
mapkey('yx', '#7download', function() { | |
Hints.create('*[href]', function(element) { | |
chrome.downloads.download(element.href); | |
}); | |
}); | |
// google search c-n/c-p | |
if (window.origin === "https://www.google.com") { | |
function cycleGoogleSuggestions(forward) { | |
var suggestions = document.querySelectorAll("ul>li.sbct"); | |
var selected = document.querySelector("ul>li.sbct.sbhl"); | |
var next; | |
if (selected) { | |
selected.classList.remove("sbhl"); | |
var next = Array.from(suggestions).indexOf(selected) + (forward ? 1 : -1); | |
if (next === suggestions.length || next === -1) { | |
next = {innerText: window.userInput}; | |
} else { | |
next = suggestions[next]; | |
next.classList.add("sbhl"); | |
} | |
} else { | |
window.userInput = document.querySelector("input.gsfi").value; | |
next = forward ? suggestions[0] : suggestions[suggestions.length - 1]; | |
next.classList.add("sbhl"); | |
} | |
document.querySelector("input.gsfi").value = next.innerText; | |
} | |
imapkey('<Ctrl-p>', 'cycle google suggestions', function () { | |
cycleGoogleSuggestions(false); | |
}); | |
imapkey('<Ctrl-n>', 'cycle google suggestions', function () { | |
cycleGoogleSuggestions(true); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment