Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexherbo2/webextension-commands
WebExtension API to perform browser actions
https://github.com/alexherbo2/webextension-commands
api chrome firefox webextension
Last synced: about 1 month ago
JSON representation
WebExtension API to perform browser actions
- Host: GitHub
- URL: https://github.com/alexherbo2/webextension-commands
- Owner: alexherbo2
- License: unlicense
- Created: 2019-10-03T16:54:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-21T17:45:41.000Z (about 1 year ago)
- Last Synced: 2024-05-21T04:25:01.441Z (8 months ago)
- Topics: api, chrome, firefox, webextension
- Language: JavaScript
- Homepage:
- Size: 19.5 KB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING
Awesome Lists containing this project
README
# Commands for [Chrome] and [Firefox] – [WebExtensions]
[Chrome]: https://google.com/chrome/
[Firefox]: https://mozilla.org/firefox/
[WebExtensions]: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions[WebExtension][WebExtensions] API to perform browser actions, such as opening a new tab.
## Dependencies
- [jq]
[jq]: https://stedolan.github.io/jq/
## Installation
###### Chrome
``` sh
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
``` sh
make firefox
```- Open `about:config`, change `xpinstall.signatures.required` to `false`.
- Open `about:addons` ❯ _Extensions_, click _Install add-on from file_ and select the package file: `target/firefox/package.zip`.## Usage
``` javascript
// Environment variables
switch (true) {
case (typeof browser !== 'undefined'):
var PLATFORM = 'firefox'
var COMMANDS_EXTENSION_ID = '[email protected]'
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].
[Krabby]: https://krabby.netlify.app
See the [source](src) for a complete reference.