dotfiles/.config/browser/extensions/surfingkeys.js

322 lines
5.8 KiB
JavaScript

// Compatibility Prefix
const {
Clipboard,
Front,
Hints,
Normal,
RUNTIME,
Visual,
aceVimMap,
addSearchAlias,
cmap,
getClickableElements,
imap,
imapkey,
iunmap,
map,
mapkey,
readText,
removeSearchAlias,
tabOpenLink,
unmap,
unmapAllExcept,
vmapkey,
vunmap,
} = api;
// toggle fullscreen, mainly because of YouTube
mapkey("F", "Fullscreen", function () {
if (window.fullScreen) {
document.exitFullscreen();
} else {
document.documentElement.requestFullscreen();
}
});
// Copy URL
map("yu", "ya");
// Buffers/Tabs
map("b", "T");
// History Back/Forward
map("H", "S");
map("L", "D");
// Next/Prev Page
map("K", "[[");
map("J", "]]");
// Scroll Page Down/Up
mapkey("<Ctrl-d>", "Scroll down", () => {
Normal.scroll("pageDown");
});
mapkey("<Ctrl-u>", "Scroll up", () => {
Normal.scroll("pageUp");
});
// --- Tabs ---
// Tab Delete/Undo
mapkey("d", "#3Close current tab", () => {
RUNTIME("closeTab");
});
mapkey("u", "#3Restore closed tab", () => {
RUNTIME("openLast");
});
// Move Tab Left/Right w/ one press
map(">", ">>");
map("<", "<<");
// Tab Next/Prev
map("<Ctrl-l>", "R");
map("<Ctrl-h>", "E");
// set theme
Hints.style(
"border: solid 2px #6e738d; color:#8aadf4; font-size: 12px; font-weight: bold; background: initial; background-color: #1e2030;",
);
Hints.style(
"border: solid 2px #6e738d !important; padding: 1px !important; color: #939ab7 !important; background: #181926 !important;",
"text",
);
Visual.style("marks", "background-color: #ed8796;");
Visual.style("cursor", "background-color: #8aadf4;");
settings.theme = `
/* Edit these variables for easy theme making */
:root {
/* Font */
--font: 'JetBrainsMono Nerd Font';
--font-size: 12;
--font-weight: bold;
--fg: #cad3f5;
--bg: #24273a;
--bg-dark: #1e2030;
--border: #6e738d;
--main-fg: #cad3f5;
--accent-fg: #b7bdf8;
--info-fg: #ed8796;
--select: #494d64;
}
/* ---------- 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.2;
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;
/* 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);
}
`;