Index

Type aliases

MessageCommand

MessageCommand: "version" | "run" | "read" | "write" | "writerc" | "temp" | "list_dir" | "mkdir" | "move" | "eval" | "getconfig" | "getconfigpath" | "env" | "win_firefox_restart"

Variables

Const NATIVE_NAME

NATIVE_NAME: "tridactyl" = "tridactyl"

Let cachedProfile

cachedProfile: any

Let cached_prefs

cached_prefs: any = null

Const logger

logger: Logger = new Logger("native")

Functions

clipboard

  • clipboard(action: "set" | "get", str: string): Promise<string>
  • Calls an external program, to either set or get the content of the X selection. When setting the selection or if getting it failed, will return an empty string.

    Parameters

    • action: "set" | "get"
    • str: string

    Returns Promise<string>

editor

  • editor(file: string, line: number, col: number, content?: string): Promise<any>
  • Parameters

    • file: string
    • line: number
    • col: number
    • Optional content: string

    Returns Promise<any>

ff_cmdline

  • ff_cmdline(): Promise<string[]>
  • This returns the commandline that was used to start firefox. You'll get both firefox binary (not necessarily an absolute path) and flags

    Returns Promise<string[]>

firstinpath

  • firstinpath(cmdarray: any): Promise<any>

getBestEditor

  • getBestEditor(): Promise<string>

getConfElsePref

  • getConfElsePref(confName: string, prefName: string): Promise<any>
  • Fetches a config option from the config. If the option is undefined, fetch a preference from preferences. It would make more sense for this function to be in config.ts but this would require importing this file in config.ts and Webpack doesn't like circular dependencies.

    Parameters

    • confName: string
    • prefName: string

    Returns Promise<any>

getConfElsePrefElseDefault

  • getConfElsePrefElseDefault(confName: string, prefName: string, def: any): Promise<any>
  • Fetches a config option from the config. If the option is undefined, fetch prefName from the preferences. If prefName is undefined too, return a default.

    Parameters

    • confName: string
    • prefName: string
    • def: any

    Returns Promise<any>

getFirefoxDir

  • getFirefoxDir(): Promise<string>

getNativeMessengerVersion

  • getNativeMessengerVersion(quiet?: boolean): Promise<number>
  • Parameters

    • Default value quiet: boolean = false

    Returns Promise<number>

getPref

  • getPref(name: string): Promise<string>
  • Returns the value for the corresponding about:config setting

    Parameters

    • name: string

    Returns Promise<string>

getPrefs

  • getPrefs(): Promise<object>
  • Returns a promise for an object that should contain every about:config setting.

    Performance is slow so we need to cache the results.

    Returns Promise<object>

getProfile

  • getProfile(): Promise<any>

getProfileDir

  • getProfileDir(): Promise<any>

getProfileName

  • getProfileName(): Promise<any>

getProfileUncached

  • getProfileUncached(): Promise<any>

getenv

  • getenv(variable: string): Promise<string>

getrc

  • getrc(): Promise<string>

getrcpath

  • getrcpath(): Promise<string>

inpath

  • inpath(cmd: any): Promise<boolean>

listDir

loadPrefs

  • loadPrefs(filename: any): Promise<object>
  • When given the name of a firefox preference file, will load said file and return a promise for an object the keys of which correspond to preference names and the values of which correspond to preference values. When the file couldn't be loaded or doesn't contain any preferences, will return a promise for an empty object.

    Parameters

    • filename: any

    Returns Promise<object>

mkdir

  • mkdir(dir: string, exist_ok: boolean): Promise<MessageResp>

move

nativegate

  • nativegate(version?: string, interactive?: boolean, desiredOS?: string[]): Promise<boolean>
  • Used internally to gate off functions that use the native messenger. Gives a helpful error message in the command line if the native messenger is not installed, or is the wrong version.

    arg

    version: A string representing the minimal required version.

    arg

    interactive: True if a message should be displayed on version mismatch.

    Parameters

    • Default value version: string = "0"
    • Default value interactive: boolean = true
    • Default value desiredOS: string[] = ["mac", "win", "linux", "openbsd"]

    Returns Promise<boolean>

    false if the required version is higher than the currently available native messenger version.

parsePrefs

  • parsePrefs(prefFileContent: string): Promise<object>

parseProfilesIni

  • parseProfilesIni(content: string, basePath: string): Promise<object>

pyeval

  • Evaluates a string in the native messenger. This has to be python code. If you want to run shell strings, use run() instead.

    Parameters

    • command: string

    Returns Promise<MessageResp>

read

run

  • run(command: string, content?: string): Promise<MessageResp>

sendNativeMsg

temp

  • temp(content: string, prefix: string): Promise<MessageResp>

winFirefoxRestart

  • winFirefoxRestart(profiledir: string, browsercmd: string): Promise<MessageResp>

write

  • write(file: string, content: string): Promise<MessageResp>

writePref

  • writePref(name: string, value: any): Promise<void>
  • Writes a preference to user.js

    Parameters

    • name: string
    • value: any

    Returns Promise<void>

writerc

  • writerc(file: string, force: boolean, content: string): Promise<MessageResp>