Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions background_scripts/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ const Commands = {
"LinkHints.activateModeToDownloadLink",
"LinkHints.activateModeToOpenIncognito",
"LinkHints.activateModeToCopyLinkUrl",
"LinkHints.activateDoubleMode",
"goPrevious",
"goNext",
"nextFrame",
Expand Down Expand Up @@ -398,6 +399,8 @@ const defaultKeyMappings = {
// Navigating the current page
"j": "scrollDown",
"k": "scrollUp",
"о": "scrollDown",
"л": "scrollUp",
"h": "scrollLeft",
"l": "scrollRight",
"gg": "scrollToTop",
Expand All @@ -408,12 +411,17 @@ const defaultKeyMappings = {
"<c-y>": "scrollUp",
"d": "scrollPageDown",
"u": "scrollPageUp",
"в": "scrollPageDown",
"г": "scrollPageUp",
"r": "reload",
"к": "reload",
"R": "hardReload",
"yy": "copyCurrentUrl",
"нн": "copyCurrentUrl",
"p": "openCopiedUrlInCurrentTab",
"P": "openCopiedUrlInNewTab",
"gi": "focusInput",
"пш": "focusInput",
"[[": "goPrevious",
"]]": "goNext",
"gf": "nextFrame",
Expand All @@ -425,8 +433,11 @@ const defaultKeyMappings = {
"V": "enterVisualLineMode",

// Link hints
"sf": "LinkHints.activateDoubleMode",
"f": "LinkHints.activateMode",
"F": "LinkHints.activateModeToOpenInNewTab",
"а": "LinkHints.activateMode",
"А": "LinkHints.activateModeToOpenInNewTab",
"<a-f>": "LinkHints.activateModeWithQueue",
"yf": "LinkHints.activateModeToCopyLinkUrl",

Expand All @@ -451,6 +462,8 @@ const defaultKeyMappings = {
// Manipulating tabs
"K": "nextTab",
"J": "previousTab",
"Л": "nextTab",
"О": "previousTab",
"gt": "nextTab",
"gT": "previousTab",
"^": "visitPreviousTab",
Expand All @@ -460,8 +473,11 @@ const defaultKeyMappings = {
"g$": "lastTab",
"W": "moveTabToNewWindow",
"t": "createTab",
"е": "createTab",
"yt": "duplicateTab",
"не": "duplicateTab",
"x": "removeTab",
"ч": "removeTab",
"X": "restoreTab",
"<a-p>": "togglePinTab",
"<a-m>": "toggleMuteTab",
Expand Down Expand Up @@ -514,6 +530,7 @@ const commandDescriptions = {
focusInput: ["Focus the first text input on the page"],

"LinkHints.activateMode": ["Open a link in the current tab"],
"LinkHints.activateDoubleMode": ["Fuck you"],
"LinkHints.activateModeToOpenInNewTab": ["Open a link in a new tab"],
"LinkHints.activateModeToOpenInNewForegroundTab": ["Open a link in a new tab & switch to it"],
"LinkHints.activateModeWithQueue": ["Open multiple links in a new tab", { noRepeat: true }],
Expand Down
56 changes: 56 additions & 0 deletions content_scripts/link_hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,15 @@ const HintCoordinator = {
};

const LinkHints = {
activateDoubleMode(count, {mode, registryEntry}) {
this.activateMode(count, {mode, registryEntry})
HintCoordinator.onExit.push(success => {
if (!success) {
return
}
this.activateMode(count, {mode, registryEntry})
})
},
activateMode(count, { mode, registryEntry }) {
if (count == null) count = 1;
if (mode == null) mode = OPEN_IN_CURRENT_TAB;
Expand Down Expand Up @@ -554,10 +563,57 @@ class LinkHintsMode {
} else if ((event.key === " ") && this.markerMatcher.shouldRotateHints(event)) {
HintCoordinator.sendMessage("rotateHints");
} else {
const map = {
'й': 'q',
'ц': 'w',
'у': 'e',
'к': 'r',
'е': 't',
'н': 'y',
'г': 'u',
'ш': 'i',
'щ': 'o',
'з': 'p',
'х': '[',
'Х': '{',
'ъ': ']',
'Ъ': '}',
'/': '|',
'ё': '`',
'Ё': '~',
'ф': 'a',
'ы': 's',
'в': 'd',
'а': 'f',
'п': 'g',
'р': 'h',
'о': 'j',
'л': 'k',
'д': 'l',
'ж': ';',
'Ж': ':',
'э': "'",
'Э': '"',
'я': 'z',
'ч': 'x',
'с': 'c',
'м': 'v',
'и': 'b',
'т': 'n',
'ь': 'm',
'б': ',',
'Б': '<',
'ю': '.',
'Ю': '>',
}

if (!event.repeat) {
let keyChar = Settings.get("filterLinkHints")
? KeyboardUtils.getKeyChar(event)
: KeyboardUtils.getKeyChar(event).toLowerCase();
if (map[keyChar]) {
keyChar = map[keyChar]
}
if (keyChar) {
if (keyChar === "space") {
keyChar = " ";
Expand Down
9 changes: 5 additions & 4 deletions content_scripts/mode_normal.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ const NormalModeCommands = {
Scroller.scrollTo("x", "max");
},
scrollUp(count) {
Scroller.scrollBy("y", -1 * Settings.get("scrollStepSize") * count);
Scroller.scrollBy("y", -1 * Settings.get("scrollStepSize") * count, 10 * count);
},
scrollDown(count) {
Scroller.scrollBy("y", Settings.get("scrollStepSize") * count);
Scroller.scrollBy("y", Settings.get("scrollStepSize") * count, 10 * count);
},
scrollPageUp(count) {
Scroller.scrollBy("y", "viewSize", (-1 / 2) * count);
Scroller.scrollBy("y", "viewSize", -document.body.clientHeight / 12_000 * count);
},
scrollPageDown(count) {
Scroller.scrollBy("y", "viewSize", (1 / 2) * count);
Scroller.scrollBy("y", "viewSize", document.body.clientHeight / 12_000 * count);
},
scrollFullPageUp(count) {
Scroller.scrollBy("y", "viewSize", -1 * count);
Expand Down Expand Up @@ -322,6 +322,7 @@ const NormalModeCommands = {
if (typeof LinkHints !== "undefined") {
Object.assign(NormalModeCommands, {
"LinkHints.activateMode": LinkHints.activateMode.bind(LinkHints),
"LinkHints.activateDoubleMode": LinkHints.activateDoubleMode.bind(LinkHints),
"LinkHints.activateModeToOpenInNewTab": LinkHints.activateModeToOpenInNewTab.bind(LinkHints),
"LinkHints.activateModeToOpenInNewForegroundTab": LinkHints.activateModeToOpenInNewForegroundTab
.bind(LinkHints),
Expand Down