webextension-toolbox

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 常用JavaScript包
软件类型 开源软件
地区 不详
投 递 者 上官彬
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

WebExtension Toolbox

Small cli toolbox for creating cross-browser WebExtensions.

If you want to get started quickly check out the yeoman generator for this project.

Browser Support

Features

React.js

Works with React out of the box!
Run $ npm i react react-dom and you are ready to go.

Packing

The build task creates bundles for:

  • Firefox (.xpi)
  • Chrome (.zip)
  • Opera (.crx)
  • Edge (.zip)

Manifest validation

Validates your manifest.json while compiling.

Manifest defaults

Uses default fields (name, version, description) from your package.json

Manifest vendor keys

Allows you to define vendor specific manifest keys.

Example

manifest.json

"name": "my-extension",
"__chrome__key": "yourchromekey",
"__chrome|opera__key2": "yourblinkkey"

If the vendor is chrome it compiles to:

"name": "my-extension",
"key": "yourchromekey",
"key2": "yourblinkkey"

If the vendor is opera it compiles to:

"name": "my-extension",
"key2": "yourblinkkey"

else it compiles to:

"name": "my-extension"

Polyfill

The WebExtension specification is currently only supported by Firefox and Edge (Trident version). This toolbox adds the necessary polyfills for Chrome, Edge (Chromium) and Opera.

This way many webextension apis will work in Chrome, Edge (Chromium) and Opera out of the box.

In addition to that, this toolbox comes with babel-preset-env.

Usage

Install

$ npm install -g webextension-toolbox

Development

  • Compiles the extension via webpack to dist/<vendor>.
  • Watches all extension files and recompiles on demand.
  • Reloads extension or extension page as soon something changed.
  • Sets process.env.NODE_ENV to development.
  • Sets process.env.VENDOR to the current vendor.

Syntax

$ webextension-toolbox dev <vendor> [..options]

Examples

$ webextension-toolbox dev --help
$ webextension-toolbox dev chrome
$ webextension-toolbox dev firefox
$ webextension-toolbox dev opera
$ webextension-toolbox dev edge

Build

  • Compile extension via webpack to dist/<vendor>.
  • Minifies extension Code.
  • Sets process.env.NODE_ENV to production.
  • Sets process.env.VENDOR to the current vendor.
  • Packs extension to packages.

Syntax

Usage: build [options] <vendor>

Compiles extension for production

Options:
  -s, --src [src]                       specify source directory (default: "app")
  -t, --target [target]                 specify target directory (default: "dist/[vendor]")
  -d, --devtool [devtool]               controls if and how source maps are generated (default: false)
  -m, --no-minimize                     disables code minification
  -v, --vendorVersion [vendorVersion]   last supported vendor (default: current)
  -h, --help                            output usage information

Browser API

Always use the WebExtension browser API. Webextension-Toolbox will polyfill it for you in chrome and opera.

Entry points

All javascript files located at the root of your ./app or ./app/scripts directory will create a seperate bundle.

app dist
app/background.js dist/<vendor>/background.js
app/scripts/background.js dist/<vendor>/scripts/background.js
app/some-dir/some-file.js Will be ignored as entry file.
app/scripts/some-dir/some-file.js Will be ignored as entry file.

Customizing webpack config

In order to extend our usage of webpack, you can define a function that extends its config via webextension-toolbox.config.js in your project root.

module.exports = {
  webpack: (config, { dev, vendor }) => {
    // Perform customizations to webpack config

    // Important: return the modified config
    return config
  }
}

As WebExtension Toolbox uses webpack’s devtool feature under the hood, you can also customize the desired devtool with the --devtool argument.

For example, if you have problems with source maps on Firefox, you can try the following command:

webextension-toolbox build firefox --devtool=inline-cheap-source-map

Please see Issue #58 for more information on this

FAQ

What is the difference to web-ext?

If want to develop browser extensions for Firefox only web-ext might be a better fit for you, since it supports, extension signing, better manifest validation and auto mounting.

Nevertheless if you want to develop cross browser extensions using

  • the same development experience in every browser
  • a single codebase
  • react
  • and custom webpack configuration

webextension-toolbox might be your tool of choice.

License

Copyright 2021 Henrik Wenz

This project is free software released under the MIT license.

 相关资料
  • This WebExtension is the official client for the Passwords app for Nextcloud for Firefox and Chromium based browsers. Features Password suggestion Search passwords Browse passwords and folders Create

  • Webpack WebExtension Plugin Webpack plugin that compiles web-extension manifest.json files and adds smart auto reload. What does it do? Autoreload extensions via websockets Use vendor prefixes in mani

  • 我想知道如何在Firefox WebExtension中访问和修改JavaScript中跨域iframe的内容。我理解普通JavaScript的局限性,也理解修改跨域iframe将是XSS漏洞,但我相信在我找不到的WebExtension中有某种方法可以做到这一点。我相信这是因为遗留扩展清单在权限部分中有允许跨域内容的选项。 当查看FireFox扩展的旧版本的旧代码时,似乎可以选择某些网站的跨域内

  • 问题内容: 所以我使用Docker Toolbox是因为我的机器上没有Hyper-V,因为它不是Windows 10专业版。一切似乎都正常,但是当我尝试使用浏览器时,它总是返回我:无法访问此站点 但是,当我运行命令时:我得到以下信息:这意味着该地址应该工作。我搜索了stackoverflow和github问题。现在我被卡住了。 我想念什么吗? 谢谢马克 编辑: 使用返回我。我在端口80上运行。除了

  • 问题内容: 我正在尝试通过Windows 7计算机上的Docker容器设置开发人员环境。 我已经为Windows安装了Docker工具箱。 我有一个包含Apache和PHP 5.6的映像,这里是: 该映像已创建,当我在Docker快速入门终端中运行“ docker映像”时可以看到它。 在我的apache-config.conf中,我只有一个小的虚拟主机,仅使用index.php文件即可访问测试网站

  • 问题内容: 通过使用Docker Toolbox启用简单命令来安装卷,如何在Windows文件和Docker 容器之间共享文件夹? 我正在使用“ Docker快速入门终端”,当我尝试这样做时: 我有这个错误: 在此之后,我也尝试了 并得到了 问题答案: 这实际上是项目的问题,有两种解决方法: 创建数据量: winpty docker run -it –rm –volumes-from data u

相关阅读

相关文章

相关问答

相关文档