Skip to content

Instantly share code, notes, and snippets.

@y9c
Last active Dec 30, 2021
Embed
What would you like to do?
surfingkeys_config.js
/*************************************************************
* File Name : surfingkeys_config.js
* Created By : Ye Chang
* Creation Date : [2017-12-22 21:55]
* Last Modified : [2021-03-24 13:35]
* Description :
**************************************************************/
// -----------------------------------------------------------------------------------------------------------------------
// - Surfingkeys: https://github.com/brookhong/Surfingkeys#properties-list
// - Dracula Theme: https://github.com/dracula/dracula-theme#color-palette
// -----------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------
// Map/Unmap Keys
// -----------------------------------------------------------------------------------------------------------------------
// scroll setting
api.map('u', 'e');
api.mapkey('p', "Open the clipboard's URL in the current tab", function () {
Front.getContentFromClipboard(function (response) {
window.location.href = response.data;
});
});
api.map('P', 'cc');
api.map('gi', 'i');
api.map('F', 'gf');
api.map('gf', 'w');
api.map('`', "'");
api.map('H', 'S');
api.map('L', 'D');
api.map('gt', 'R');
api.map('gT', 'E');
api.map('K', 'R');
api.map('J', 'E');
api.unmap('se');
// map keys for certain sites
api.unmapAllExcept(
['H', 'L', 'J', 'K', 'gg', 'G', 'd', 'u', 'f', 'F'],
/gmail.com|twitter.com/
);
// -----------------------------------------------------------------------------------------------------------------------
// Settings API
// -----------------------------------------------------------------------------------------------------------------------
// settings.nextLinkRegex = "/((>>|next|chevron_right)+)/i";
// settings.prevLinkRegex = "/((<<|prev(ious)?|chevron_left)+)/i";
// -----------------------------------------------------------------------------------------------------------------------
// Search Engines
// -----------------------------------------------------------------------------------------------------------------------
api.addSearchAlias('at', 'alternativeto', 'http://alternativeto.net/software/');
api.addSearchAlias('oh', 'openhub', 'http://code.openhub.net/search?s=/');
api.addSearchAlias('rs', 'rseek', 'http://www.rseek.org/?q=');
api.addSearchAlias(
'gs',
'scholar',
'https://scholar.google.com/scholar?hl=en&as_sdt=0%2C14='
);
// -----------------------------------------------------------------------------------------------------------------------
// Dictionary
// -----------------------------------------------------------------------------------------------------------------------
const API_KEY = 'e9b1790b-b907-4e80-b090-06e0052eb4fe';
const API_URL = 'https://dictionaryapi.com/api/v3';
// api.Front.registerInlineQuery({
// url: function(q) {
// var word = q.trim().toLowerCase();
// const url = `${API_URL}/references/learners/json/${word}?key=${API_KEY}`;
// return url;
// },
// parseResult: function(res) {
// try {
// const [firstResult] = JSON.parse(res.text);
// if (firstResult) {
// let definitionsList = `<ul><li>No definitions found</li></ul>`;
// let pronunciationsList = `<ul><li>No pronunciations found</li></ul>`;
// if (firstResult.hasOwnProperty('shortdef')) {
// const definitions = [];
// for (let definition of firstResult.shortdef) {
// definitions.push(`${definition}`);
// }
// const definitionListItems = definitions.map(function(definition) {
// return `<li>${definition}</li>`;
// });
// definitionsList = `<ul>${definitionListItems.join('')}</ul>`;
// //TODO: Separate this function if possible
// }
// if (firstResult.hasOwnProperty('hwi')) {
// const pronunciations = [];
// const resultPronunciationsArray = firstResult.hwi.prs;
// if (resultPronunciationsArray && resultPronunciationsArray.length !== 0) {
// for (let i=0; i < resultPronunciationsArray.length; i++) {
// if (resultPronunciationsArray[i].l) {
// pronunciations.push(`<li>${resultPronunciationsArray[i].l} -- ${resultPronunciationsArray[i].ipa}</li>`);
// } else {
// pronunciations.push(`<li>${resultPronunciationsArray[i].ipa}</li>`);
// }
// }
//
// pronunciationsList = `<ul>${pronunciations.join('')}</ul>`;
// }
// }
// return `
// <h3>Pronunciations</h3>
// ${pronunciationsList}
// <hr/>
// <h3>Definitions</h3>
// ${definitionsList}
// `;
// } else {
// return `
// <h3>This is not the definition you were looking for...</h3>
// `;
// }
// } catch (e) {
// console.log(e.message);
// return 'Something bad happend... Look behind you, a three headed monkey!';
// }
// }
// });
// -----------------------------------------------------------------------------------------------------------------------
// Change hints styles
// -----------------------------------------------------------------------------------------------------------------------
api.Hints.characters = 'asdfgqwertvbn';
api.Hints.style(
'border: solid 0px #ff79c6; color:#44475a; background: #f1fa8c; background-color: #f1fa8c; font-size: 9pt; font-family: "PragmataPro"'
);
api.Hints.style(
"border: solid 0px #ff79c6; padding: 1px; background: #7FAB97; font-size: 9pt; font-family: 'PragmataPro'",
'text'
);
settings.hintAlign = 'left';
// -----------------------------------------------------------------------------------------------------------------------
// Change search marks and cursor
// -----------------------------------------------------------------------------------------------------------------------
api.Visual.style('marks', 'background-color: #f1fa8c;');
api.Visual.style('cursor', 'background-color: #6272a4; color: #f8f8f2');
// -----------------------------------------------------------------------------------------------------------------------
// Change theme (fonts, color)
// -----------------------------------------------------------------------------------------------------------------------
settings.theme = `
/* Edit these variables for easy theme making */
:root {
/* Font */
--font: 'Source Code Pro', Ubuntu, sans;
--font-size: large;
--font-weight: normal;
/* -------------- */
/* --- THEMES --- */
/* -------------- */
/* -------------------- */
/* -- Tomorrow Night -- */
/* -------------------- */
/* -- DELETE LINE TO ENABLE THEME
--fg: #C5C8C6;
--bg: #282A2E;
--bg-dark: #1D1F21;
--border: #373b41;
--main-fg: #81A2BE;
--accent-fg: #52C196;
--info-fg: #AC7BBA;
--select: #585858;
-- DELETE LINE TO ENABLE THEME */
/* Unused Alternate Colors */
/* --cyan: #4CB3BC; */
/* --orange: #DE935F; */
/* --red: #CC6666; */
/* --yellow: #CBCA77; */
/* -------------------- */
/* -- NORD -- */
/* -------------------- */
/* -- DELETE LINE TO ENABLE THEME
--fg: #E5E9F0;
--bg: #3B4252;
--bg-dark: #2E3440;
--border: #4C566A;
--main-fg: #88C0D0;
--accent-fg: #A3BE8C;
--info-fg: #5E81AC;
--select: #4C566A;
-- DELETE LINE TO ENABLE THEME */
/* Unused Alternate Colors */
/* --orange: #D08770; */
/* --red: #BF616A; */
/* --yellow: #EBCB8B; */
/* -------------------- */
/* -- DOOM ONE -- */
/* -------------------- */
--fg: #51AFEF;
--bg: #2E3440;
--bg-dark: #21242B;
--border: #2257A0;
--main-fg: #51AFEF;
--accent-fg: #98be65;
--info-fg: #C678DD;
--select: #4C566A;
/* Unused Alternate Colors */
/* --border-alt: #282C34; */
/* --cyan: #46D9FF; */
/* --orange: #DA8548; */
/* --red: #FF6C6B; */
/* --yellow: #ECBE7B; */
/* -------------------- */
/* -- MONOKAI -- */
/* -------------------- */
/* -- DELETE LINE TO ENABLE THEME
--fg: #F8F8F2;
--bg: #272822;
--bg-dark: #1D1E19;
--border: #2D2E2E;
--main-fg: #F92660;
--accent-fg: #E6DB74;
--info-fg: #A6E22E;
--select: #556172;
-- DELETE LINE TO ENABLE THEME */
/* Unused Alternate Colors */
/* --red: #E74C3C; */
/* --orange: #FD971F; */
/* --blue: #268BD2; */
/* --violet: #9C91E4; */
/* --cyan: #66D9EF; */
}
/* ---------- Generic ---------- */
.sk_theme {
background: var(--bg);
color: var(--fg);
background-color: var(--bg);
border-color: var(--border);
font-family: var(--font);
font-size: var(--font-size);
font-weight: var(--font-weight);
}
input {
font-family: var(--font);
font-weight: var(--font-weight);
}
.sk_theme tbody {
color: var(--fg);
}
.sk_theme input {
color: var(--fg);
}
/* Hints */
#sk_hints .begin {
color: var(--accent-fg) !important;
}
#sk_tabs .sk_tab {
background: var(--bg-dark);
border: 1px solid var(--border);
}
#sk_tabs .sk_tab_title {
color: var(--fg);
}
#sk_tabs .sk_tab_url {
color: var(--main-fg);
}
#sk_tabs .sk_tab_hint {
background: var(--bg);
border: 1px solid var(--border);
color: var(--accent-fg);
}
.sk_theme #sk_frame {
background: var(--bg);
opacity: 0.5;
color: var(--accent-fg);
}
/* ---------- Omnibar ---------- */
/* Uncomment this and use settings.omnibarPosition = 'bottom' for Pentadactyl/Tridactyl style bottom bar */
/* .sk_theme#sk_omnibar {
width: 100%;
left: 0;
} */
.sk_theme .title {
color: var(--accent-fg);
}
.sk_theme .url {
color: var(--main-fg);
}
.sk_theme .annotation {
color: var(--accent-fg);
}
.sk_theme .omnibar_highlight {
color: var(--accent-fg);
}
.sk_theme .omnibar_timestamp {
color: var(--info-fg);
}
.sk_theme .omnibar_visitcount {
color: var(--accent-fg);
}
.sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) {
background: var(--bg-dark);
}
.sk_theme #sk_omnibarSearchResult ul li.focused {
background: var(--border);
}
.sk_theme #sk_omnibarSearchArea {
border-top-color: var(--border);
border-bottom-color: var(--border);
}
.sk_theme #sk_omnibarSearchArea input,
.sk_theme #sk_omnibarSearchArea span {
font-size: var(--font-size);
}
.sk_theme .separator {
color: var(--accent-fg);
}
/* ---------- Popup Notification Banner ---------- */
#sk_banner {
font-family: var(--font);
font-size: var(--font-size);
font-weight: var(--font-weight);
background: var(--bg);
border-color: var(--border);
color: var(--fg);
opacity: 0.9;
}
/* ---------- Popup Keys ---------- */
#sk_keystroke {
background-color: var(--bg);
}
.sk_theme kbd .candidates {
color: var(--info-fg);
}
.sk_theme span.annotation {
color: var(--accent-fg);
}
/* ---------- Popup Translation Bubble ---------- */
#sk_bubble {
background-color: var(--bg) !important;
color: var(--fg) !important;
border-color: var(--border) !important;
}
#sk_bubble * {
color: var(--fg) !important;
}
#sk_bubble div.sk_arrow div:nth-of-type(1) {
border-top-color: var(--border) !important;
border-bottom-color: var(--border) !important;
}
#sk_bubble div.sk_arrow div:nth-of-type(2) {
border-top-color: var(--bg) !important;
border-bottom-color: var(--bg) !important;
}
/* ---------- Search ---------- */
#sk_status,
#sk_find {
font-size: var(--font-size);
border-color: var(--border);
}
.sk_theme kbd {
background: var(--bg-dark);
border-color: var(--border);
box-shadow: none;
color: var(--fg);
}
.sk_theme .feature_name span {
color: var(--main-fg);
}
/* ---------- ACE Editor ---------- */
#sk_editor {
background: var(--bg-dark) !important;
height: 50% !important;
font-family: monospace !important;
font-szie: x-large !important
/* Remove this to restore the default editor size */
}
.ace_dialog-bottom {
border-top: 1px solid var(--bg) !important;
}
.ace-chrome .ace_print-margin,
.ace_gutter,
.ace_gutter-cell,
.ace_dialog {
background: var(--bg) !important;
}
.ace-chrome {
color: var(--fg) !important;
}
.ace_gutter,
.ace_dialog {
color: var(--fg) !important;
}
.ace_cursor {
color: var(--fg) !important;
}
.normal-mode .ace_cursor {
background-color: var(--fg) !important;
border: var(--fg) !important;
opacity: 0.7 !important;
}
.ace_marker-layer .ace_selection {
background: var(--select) !important;
}
.ace_editor,
.ace_dialog span,
.ace_dialog input {
font-family: var(--font);
font-size: var(--font-size);
font-weight: var(--font-weight);
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment