diff --git a/src/hinting.ts b/src/hinting.ts index c6f7498d..fe9ae857 100644 --- a/src/hinting.ts +++ b/src/hinting.ts @@ -527,6 +527,44 @@ function hintPageOpenInBackground() { }) } +// lazily copied from excmds.ts - really ought to be moved to lib/webext +async function winopen(...args: string[]) { + let address: string + const createData = {} + if (args[0] === "-private") { + createData["incognito"] = true + address = args.slice(1,args.length).join(' ') + } else address = args.join(' ') + browser.windows.create(createData) +} + + +function hintPageWindow() { + hintPage(hintables(), hint=>{ + hint.target.focus() + if (hint.target.href) { + winopen(hint.target.href) + } else { + // This is to mirror vimperator behaviour. + simulateClick(hint.target) + } + }) +} + +function hintPageWindowPrivate() { + hintPage(hintables(), hint=>{ + hint.target.focus() + if (hint.target.href) { + // Try to open with the webext API. + winopen("--private",hint.target.href) + } else { + // Private window, so never fall back to opening in current tab + // This is to mirror vimperator behaviour. + // simulateClick(hint.target) + } + }) +} + function hintPageSimple(selectors=HINTTAGS_selectors) { hintPage(hintables(selectors), hint=>{ simulateClick(hint.target) diff --git a/src/hinting_background.ts b/src/hinting_background.ts index 3f471bdf..f16f27f4 100644 --- a/src/hinting_background.ts +++ b/src/hinting_background.ts @@ -32,6 +32,13 @@ export async function hintPageOpenInBackground() { return await messageActiveTab('hinting_content', 'hintPageOpenInBackground') } +export async function hintPageWindow() { + return await messageActiveTab('hinting_content', 'hintPageWindow') +} + +export async function hintPageWindowPrivate() { + return await messageActiveTab('hinting_content', 'hintPageWindowPrivate') +} export async function hintImage(inBackground) { return await messageActiveTab('hinting_content', 'hintImage', [inBackground]) }