mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 17:11:40 -05:00
Add jsua for --mode=browser binds
Works like jsb but preserves the 'user action' so it can be used to open/close the sidebar, open downloaded files etc. Example usage: `:bind --mode=browser <C-.> jsua browser.sidebarAction.close()`
This commit is contained in:
parent
c77bf89d0c
commit
09172391a5
2 changed files with 14 additions and 7 deletions
|
@ -6,12 +6,14 @@ import * as controller from "@src/lib/controller"
|
|||
function makelistener(commands: Array<browser.commands.Command>) {
|
||||
return (command_name: string) => {
|
||||
const command = commands.filter(c => c.name == command_name)[0]
|
||||
const exstring = config.get(
|
||||
const [excmd, ...exargs] = config
|
||||
.get(
|
||||
"browsermaps",
|
||||
keyseq.mozMapToMinimalKey(command.shortcut).toMapstr(),
|
||||
)
|
||||
if (exstring in useractions) return useractions[exstring]()
|
||||
return controller.acceptExCmd(exstring)
|
||||
.split(" ")
|
||||
if (excmd in useractions) return useractions[excmd](...exargs)
|
||||
return controller.acceptExCmd([excmd, ...exargs].join(" "))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,12 @@ function sidebartoggle() {
|
|||
return browser.sidebarAction.toggle()
|
||||
}
|
||||
|
||||
export const useractions: Record<string, () => void> = {
|
||||
function jsua(...args: string[]) {
|
||||
return eval(args.join(" "))
|
||||
}
|
||||
|
||||
export const useractions: Record<string, (...args: string[]) => void> = {
|
||||
escapehatch,
|
||||
sidebartoggle,
|
||||
jsua,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue