Skip to content

Instantly share code, notes, and snippets.

@ivanmilov
Created February 7, 2021 13:04
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 ivanmilov/de22527101a6cdd5001ad708453e600d to your computer and use it in GitHub Desktop.
Save ivanmilov/de22527101a6cdd5001ad708453e600d to your computer and use it in GitHub Desktop.
surfingkey configuration
// an example to create a new mapping `ctrl-y`
/*
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).');
});
*/
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
map('gt', 'T');
// remove a keystroke mapping
// https://github.com/brookhong/Surfingkeys#remove-a-keystroke-mapping
// an example to remove mapkey `Ctrl-i`
unmap('<Ctrl-i>');
unmap('<Ctrl-h>'); // disable Mouse over elements
unmap('<Ctrl-j>'); // disable Mouse out elements.
unmap('t'); // disable t open omnibar getAllSites
unmap('r'); // disable r (reload page)
iunmap(":"); // disable emoji
// unmap in insert mode
iunmap('<Ctrl-i>');
iunmap('<Ctrl-e>');
iunmap('<Ctrl-f>');
iunmap('<Ctrl-u>');
unmap('f');
mapkey('cc', '#1Open a link, press SHIFT to flip overlapped hints, hold SPACE to hide hints',
function() {Hints.create("", Hints.dispatchMouseClick);});
unmap('gf');
mapkey('cb', '#1Open a link in Backgroung new tab', function() {
Hints.create("", Hints.dispatchMouseClick, {tabbed: true, active: false});
});
unmap('af');
mapkey('ca', '#1Open a link in Active new tab', function() {
Hints.create("", Hints.dispatchMouseClick, {tabbed: true, active: true});
});
unmap('cf');
mapkey('cm', '#1Open Multiple links in a new tab', function() {
Hints.create("", Hints.dispatchMouseClick, {multipleHits: true});
});
unmap('Q');
mapkey('Q', '#8Open omnibar for word translation', function() {
Front.openOmniquery({query: Normal.getWordUnderCursor(), style: "opacity: 1;"});
});
settings.blacklistPattern = /.*youtube.com.*/i;
settings.blacklistPattern = /.*play.geforcenow.com.*/i;
// set theme gruvbox (Dark)
/* settings.theme = `
.sk_theme {
font-family: Input Sans Condensed, Charcoal, sans-serif;
font-size: 10pt;
background: #282828;
color: #ebdbb2;
}
.sk_theme .frame {
background: rgba(129, 120, 222, 1);
}
#sk_omnibar {
opacity: 1;
overflow: hidden;
position: fixed;
width: 80%;
max-height: 80%;
left: 10%;
text-align: left;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 1);
z-index: 2147483000;
}
.sk_theme tbody {
color: #b8bb26;
}
.sk_theme input {
color: #d9dce0;
}
.sk_theme .url {
color: #98971a;
}
.sk_theme .annotation {
color: #b16286;
}
.sk_theme .omnibar_highlight {
color: #ebdbb2;
}
.sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) {
background: #282828ff;
}
.sk_theme #sk_omnibarSearchResult ul li.focused {
background: #d3869b;
}
#sk_status, #sk_find {
font-size: 20pt;
}
`; */
// set theme Spacemacs
settings.theme = `
.sk_theme {
font-family: Input Sans Condensed, Charcoal, sans-serif;
font-size: 10pt;
background: #24272e;
color: #abb2bf;
}
.sk_theme tbody {
color: #fff;
}
.sk_theme input {
color: #d0d0d0;
}
.sk_theme .url {
color: #61afef;
}
.sk_theme .annotation {
color: #56b6c2;
}
.sk_theme .omnibar_highlight {
color: #528bff;
}
.sk_theme .omnibar_timestamp {
color: #e5c07b;
}
.sk_theme .omnibar_visitcount {
color: #98c379;
}
.sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) {
background: #303030;
}
.sk_theme #sk_omnibarSearchResult ul li.focused {
background: #3e4452;
}
#sk_status, #sk_find {
font-size: 20pt;
}`;
// click `Save` button to make above settings to take effect.
Front.registerInlineQuery({
url: function(q) {
return `https://www.multitran.com/m.exe?l1=2&l2=3&s=${q}`;
},
parseResult: function(res) {
var parser = new DOMParser();
var doc = parser.parseFromString(res.text, "text/html");
var list = " <\/li><ul>";
function foo(trans){
doc.querySelectorAll("td." + trans).forEach(
function(tr){
list += "<li>";
tr.querySelectorAll("a").forEach(
function(a){
list += a.innerHTML + ", ";
});
var spans = tr.querySelectorAll("span");
if(spans){
spans.forEach(function(span){
span.querySelectorAll('i').forEach(function(i){
i.remove();
});
list += span.outerHTML + ", ";
});
}
list += "<\/li>";
});
};
foo("trans");
foo("trans1");
foo("trans2");
list += "<\/ul>";
return list;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment