Skip to content

Latest commit

 

History

History
165 lines (118 loc) · 3.36 KB

API.md

File metadata and controls

165 lines (118 loc) · 3.36 KB

API

The Velocity API is exposed through the Velocity global object.

Functions

  • getTabs - Returns an array of all open tabs
  • getBookmarks - Returns an array of all bookmarks
  • getProtocol - Returns an array of all protocols

Classes

Tab - Open new tabs

Paramaters

  • URL - A string representing the URL to open
  • setActive - A boolean value to focus the newly opened tab

Methods

  • goBack - Navigate backwards in history
  • goForward - Navigate forwards in history
  • reload - Reload the tab
  • stop - Stop the tab from loading any further
  • navigate - Navigate to a new URL
    • URL - A string representing where to navigate to
  • close - Close the tab
  • bookmark - Bookmark the tab as it is
  • executeScript - Evaluate JavaScript inside the tab scope
  • setDevTools - Open/close Eruda dev tools
    • isOpen - A boolean value representing the dev tool open status

Values

TODO

Example

new Tab("about:newTab", true); // Open a new tab

Bookmark - Create new bookmarks

Paramaters

  • options
    • name - Display name for bookmark
    • url - Bookmark URL
    • icon - URL to bookmark icon
    • id? - Optional ID feild

Methods

  • delete - Delete the bookmark

Example

new Bookmark({
  name: "Radon Games",
  url: "https://radon.games/",
  icon: "https://radon.games/favicon.ico"
});

Protocol - Create custom protocols

Paramaters

  • prefix - Prefix to use for the protocol

Methods

  • register - Register a new domain
    • domain - A string representing the domain ("*" for wildcard)
    • URL - A string URL to map the domain to

Example

const proto = new Protocol("rd");

proto.register("*", "https://radon.games/");

ContextItem - Modify context menus

Paramaters

  • options
    • separator? - Boolean value to consider item a separator
    • text? - Text value of the context button
    • onClick? - A function that is executed when a user clicks the button

Example

element.addEventListener("contextmenu", (event) => {
  event.data = event.data ?? [];

  event.data.push(
    new ContextItem({
      text: "Click me!",
      onClick: () => {
        alert("You clicked me!");
      }
    })
  );
});

Keybind - Create new keybinds

Paramaters

  • options
    • name - Name of keybind
    • description - Description of keybind
    • key - Non case sensitive key
    • ctrl? - Boolean to require ctrl
    • shift? - Boolean to require shift
    • alt? - Boolean to require alt
    • meta? - Boolean to require meta
    • callback - Callback when keybind is run
      • event - Keyboard event

Methods

  • toString - Return the keybind as a readable string

Example

new Keybind({
  name: "Find",
  description: "Find text in page",
  key: "f",
  ctrl: true,
  callback(event) {
    // do something
    alert("You ran the keybind!");
  }
});

Objects

history - Modify history entries

Methods

  • add - Async function to add or modify history entries
  • get - Async function to get all entries
    • tab? - the Tab object to add or modify in history
  • delete - Async function to delete an entry
    • id - the history object id <Tab>.historyId
  • clear - Async function clear all entries

Example

await history.clear();