Add hint window/private (untested)

This commit is contained in:
Oliver Blanthorn 2018-03-11 12:53:02 +00:00
parent e43f4fae41
commit b8e1131281
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
2 changed files with 45 additions and 0 deletions

View file

@ -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)

View file

@ -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])
}