diff --git a/content_scripts/vimium_frontend.js b/content_scripts/vimium_frontend.js index c4d5331ec..d25d0c855 100644 --- a/content_scripts/vimium_frontend.js +++ b/content_scripts/vimium_frontend.js @@ -250,22 +250,31 @@ const onFocus = forTrusted(function (event) { globalThis.addEventListener("focus", onFocus, true); globalThis.addEventListener("hashchange", checkEnabledAfterURLChange, true); -async function initializeOnDomReady() { +async function initializeOnDomReady(){ // Tell the background page we're in the domReady state. - await chrome.runtime.sendMessage({ handler: "domReady" }); - + await chrome.runtime.sendMessage({handler: "domReady"}); + const isVimiumNewTabPage = document.location.href == Settings.vimiumNewTabPageUrl; - if (!isVimiumNewTabPage) return; - // Show the Vomnibar. + //Ensure Settings are loaded before accessing them. await Settings.onLoaded(); - if (Settings.get("openVomnibarOnNewTabPage")) { - await Utils.populateBrowserInfo(); - DomUtils.injectUserCss(); - Vomnibar.activate(0, {}); + + //On Vimium's new-tab page, optionally show the Vomnibar. + if(isVimiumNewTabPage) { + if (Settings.get("openVomnibarOnNewTabPage")){ + await Utils.populateBrowserInfo(); + DomUtils.injectUserCss(); + Vomnibar.activate(0, {}); + } } -} + // Automatically enter link-hints mode on page load if enabled in settings. + // Just mirrors what happens when user presses "f" on page load. + if (isEnabledForUrl && Settings.get("autoActivateLinkHints") && globalThis.LinkHints){ + // Pass an empty options obbject so activateMode's destructing succeeds. + globalThis.LinkHints.activateMode(1, {}); + } +} const onUnload = Utils.makeIdempotent(() => { HintCoordinator.exit({ isSuccess: false }); handlerStack.reset(); diff --git a/lib/settings.js b/lib/settings.js index 569ba4f5d..91e96277f 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -80,6 +80,7 @@ w: https://www.wikipedia.org/w/index.php?title=Special:Search&search=%s Wikipedi waitForEnterForFilteredHints: true, helpDialog_showAdvancedCommands: false, ignoreKeyboardLayout: false, + autoActivateLinkHints: false, }; /* diff --git a/pages/options.html b/pages/options.html index 1cc84fa90..8f285257b 100644 --- a/pages/options.html +++ b/pages/options.html @@ -173,6 +173,15 @@

When enabled, the HUD will not be displayed in insert mode.
+ +

+ +
+ When enabled, Vimium will behave as if you pressed f after each page loads. +