Skip to content

Instantly share code, notes, and snippets.

@fno2010
Created January 23, 2019 19:40
Show Gist options
  • Save fno2010/42c0d957af159562efde4a972701fd93 to your computer and use it in GitHub Desktop.
Save fno2010/42c0d957af159562efde4a972701fd93 to your computer and use it in GitHub Desktop.
Local settings for chrome surfingkeys
// set theme
// settings.theme = `
// .sk_theme {
// background: #000;
// color: #fff;
// }
// .sk_theme tbody {
// color: #fff;
// }
// .sk_theme input {
// color: #d9dce0;
// }
// .sk_theme .url {
// color: #2173c5;
// }
// .sk_theme .annotation {
// color: #38f;
// }
// .sk_theme .omnibar_highlight {
// color: #fbd60a;
// }
// .sk_theme ul>li:nth-child(odd) {
// background: #1e211d;
// }
// .sk_theme ul>li.focused {
// background: #4ec10d;
// }`;
// register inline-query
Front.registerInlineQuery({
url: "https://api.shanbay.com/bdc/search/?word=",
parseResult: function(res) {
try {
res = JSON.parse(res.text);
var exp = res.msg;
if (res.data.definition) {
var pronunciations = [];
for (var reg in res.data.pronunciations) {
pronunciations.push(`<div>[${reg}] ${res.data.pronunciations[reg]}</div>`);
// pronunciations.push(`<div><audio src="${res.data[reg+'_audio']}" controls></audio></div>`);
}
var definition = res.data.definition.split("\n").map(function(d) {
return `<li>${d}</li>`;
}).join("");
exp = `${pronunciations.join("")}<ul>${definition}</ul>`;
}
if (res.data.en_definitions) {
exp += "<hr/>";
for (var lex in res.data.en_definitions) {
var sense = res.data.en_definitions[lex].map(function(s) {
return `<li>${s}</li>`;
}).join("");
exp += `<div>${lex}</div><ul>${sense}</ul>`;
}
}
return exp;
} catch (e) {
return "";
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment