Skip to content

alexherbo2/webextension-commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commands for Chrome and FirefoxWebExtensions

WebExtension API to perform browser actions, such as opening a new tab.

Dependencies

Installation

Chrome
make chrome

Open the Extensions page by navigating to chrome://extensions, enable Developer mode then Load unpacked to select the extension directory: target/chrome.

Firefox
make firefox
  • Open about:config, change xpinstall.signatures.required to false.
  • Open about:addonsExtensions, click Install add-on from file and select the package file: target/firefox/package.zip.

Usage

// Environment variables
switch (true) {
  case (typeof browser !== 'undefined'):
    var PLATFORM = 'firefox'
    var COMMANDS_EXTENSION_ID = 'commands@alexherbo2.github.com'
    break
  case (typeof chrome !== 'undefined'):
    var PLATFORM = 'chrome'
    var COMMANDS_EXTENSION_ID = 'cabmgmngameccclicfmcpffnbinnmopc'
    break
}

// Initialization
const commands = {}
commands.port = chrome.runtime.connect(COMMANDS_EXTENSION_ID)
commands.send = (command, ...arguments) => {
  commands.port.postMessage({ command, arguments })
}

// Usage
commands.send('new-tab', 'https://github.com')

You can find some examples in Krabby.

See the source for a complete reference.

About

WebExtension API to perform browser actions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published