Skip to content

Instantly share code, notes, and snippets.

@fno2010
Last active January 2, 2022 12:08
Show Gist options
  • Save fno2010/18f4bce433a1303ed5ef4f7bc6e939c8 to your computer and use it in GitHub Desktop.
Save fno2010/18f4bce433a1303ed5ef4f7bc6e939c8 to your computer and use it in GitHub Desktop.
Surfingkeys dot configuration file
// Migrate settings to 1.0
// Refer to: https://github.com/brookhong/Surfingkeys/wiki/Migrate-your-settings-from-0.9.74-to-1.0
const {
aceVimMap,
mapkey,
imap,
imapkey,
getClickableElements,
vmapkey,
map,
unmap,
vunmap,
cmap,
addSearchAlias,
removeSearchAlias,
tabOpenLink,
readText,
Clipboard,
Front,
Hints,
Visual,
RUNTIME
} = api;
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
map('gt', 'T');
// an example to remove mapkey `Ctrl-i`
unmap('<Ctrl-i>');
// set theme
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;
}`;
// Register inline query dictionary
Front.registerInlineQuery({
url: function(q) {
return `http://dict.youdao.com/w/eng/${q}/#keyfrom=dict2.index`;
},
parseResult: function(res) {
var parser = new DOMParser();
var doc = parser.parseFromString(res.text, "text/html");
var collinsResult = doc.querySelector("#collinsResult");
var authTransToggle = doc.querySelector("#authTransToggle");
var examplesToggle = doc.querySelector("#examplesToggle");
if (collinsResult) {
collinsResult.querySelectorAll("div>span.collinsOrder").forEach(function(span) {
span.nextElementSibling.prepend(span);
});
collinsResult.querySelectorAll("div.examples").forEach(function(div) {
div.innerHTML = div.innerHTML.replace(/<p/gi, "<span").replace(/<\/p>/gi, "</span>");
});
var exp = collinsResult.innerHTML;
return exp;
} else if (authTransToggle) {
authTransToggle.querySelector("div.via.ar").remove();
return authTransToggle.innerHTML;
} else if (examplesToggle) {
return examplesToggle.innerHTML;
}
}
});
// click `Save` button to make above settings to take effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment