diff --git a/background_scripts/commands.js b/background_scripts/commands.js index 8fa8c29c4..1388c007f 100644 --- a/background_scripts/commands.js +++ b/background_scripts/commands.js @@ -315,6 +315,7 @@ const Commands = { "LinkHints.activateModeToDownloadLink", "LinkHints.activateModeToOpenIncognito", "LinkHints.activateModeToCopyLinkUrl", + "LinkHints.activateDoubleMode", "goPrevious", "goNext", "nextFrame", @@ -398,6 +399,8 @@ const defaultKeyMappings = { // Navigating the current page "j": "scrollDown", "k": "scrollUp", + "о": "scrollDown", + "л": "scrollUp", "h": "scrollLeft", "l": "scrollRight", "gg": "scrollToTop", @@ -408,12 +411,17 @@ const defaultKeyMappings = { "": "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", @@ -425,8 +433,11 @@ const defaultKeyMappings = { "V": "enterVisualLineMode", // Link hints + "sf": "LinkHints.activateDoubleMode", "f": "LinkHints.activateMode", "F": "LinkHints.activateModeToOpenInNewTab", + "а": "LinkHints.activateMode", + "А": "LinkHints.activateModeToOpenInNewTab", "": "LinkHints.activateModeWithQueue", "yf": "LinkHints.activateModeToCopyLinkUrl", @@ -451,6 +462,8 @@ const defaultKeyMappings = { // Manipulating tabs "K": "nextTab", "J": "previousTab", + "Л": "nextTab", + "О": "previousTab", "gt": "nextTab", "gT": "previousTab", "^": "visitPreviousTab", @@ -460,8 +473,11 @@ const defaultKeyMappings = { "g$": "lastTab", "W": "moveTabToNewWindow", "t": "createTab", + "е": "createTab", "yt": "duplicateTab", + "не": "duplicateTab", "x": "removeTab", + "ч": "removeTab", "X": "restoreTab", "": "togglePinTab", "": "toggleMuteTab", @@ -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 }], diff --git a/content_scripts/link_hints.js b/content_scripts/link_hints.js index 7b23d82ef..98ec9a0b8 100644 --- a/content_scripts/link_hints.js +++ b/content_scripts/link_hints.js @@ -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; @@ -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 = " "; diff --git a/content_scripts/mode_normal.js b/content_scripts/mode_normal.js index e6fe40888..53361bf0b 100644 --- a/content_scripts/mode_normal.js +++ b/content_scripts/mode_normal.js @@ -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); @@ -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),