How to use web-ext - 10 common examples

To help you get started, we’ve selected a few web-ext examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cliqz-oss / browser-core / tests / runners / launchers / firefox-web-ext.js View on Github external
const webExt = require('web-ext').default;
const path = require('path');
const getOptionsUrl = require('./test-options');

const prefsFromTalos = {
  // From Talos project
  'app.update.enabled': false,
  'browser.bookmarks.max_backups': 0,
  'browser.cache.disk.smart_size.enabled': false,
  'browser.cache.disk.smart_size.first_run': false,
  'browser.chrome.dynamictoolbar': false,
  'browser.dom.window.dump.enabled': true,
  'browser.EULA.override': true,
  // Disable checking if firefox is default browser
  'browser.shell.checkDefaultBrowser': false,
  'browser.warnOnQuit': false,
  'browser.tabs.remote.autostart': false,
github kumabook / bebop / index.js View on Github external
const webpack = require('webpack');
const webExt  = require('web-ext').default;
const config  = require('./webpack.config');

const compiler = webpack(config);
const watching = compiler.watch({ aggregateTimeout: 1000 }, (err) => {
  /* eslint-disable no-console */
  if (err) {
    console.log('\nFailed to webpack build');
  } else {
    console.log('\nweback built');
  }
});

webExt.cmd.run({
  firefox:        process.env.FIREFOX_BINARY,
  sourceDir:      process.cwd(),
  ignoreFiles:    process.env.IGNORE_FILES.split(' ').concat('**/*~'),
  browserConsole: true,
  firefoxProfile: process.env.FIREFOX_PROFILE,
}, {
  shouldExitProgram: false,
}).then(runner => runner.registerCleanup(() => watching.close()));
github kumabook / bebop / index.js View on Github external
const webpack = require('webpack');
const webExt  = require('web-ext').default;
const config  = require('./webpack.config');

const compiler = webpack(config);
const watching = compiler.watch({ aggregateTimeout: 1000 }, (err) => {
  /* eslint-disable no-console */
  if (err) {
    console.log('\nFailed to webpack build');
  } else {
    console.log('\nweback built');
  }
});

webExt.cmd.run({
  firefox:        process.env.FIREFOX_BINARY,
  sourceDir:      process.cwd(),
  ignoreFiles:    process.env.IGNORE_FILES.split(' ').concat('**/*~'),
github treosh / exthouse / src / utils / measure-firefox.js View on Github external
exports.measureFirefox = async function(url, ext) {
  let extensionRunners
  let browser

  if (ext.path) {
    // @todo wait for https://github.com/sindresorhus/get-port/pull/28 and than use range for 6000 port
    const CDPPort = await getPort()

    extensionRunners = await webExt.cmd.run(
      {
        sourceDir: ext.path,
        // comment if connect to default FF
        firefox: PP_FF.executablePath(),
        args: [`-juggler=${CDPPort}`]
      },
      {
        // These are non CLI related options for each function.
        // You need to specify this one so that your NodeJS application
        // can continue running after web-ext is finished.
        shouldExitProgram: false
      }
    )

    const browserWSEndpoint = `ws://127.0.0.1:${CDPPort}`
    browser = await PP_FF.connect({
github danhumphrey / page-modeller / gulpfile.js View on Github external
(function(console) {
  "use strict";

  const pkg = require("./package.json");

  const gulp = require("gulp");
  const webext = require("web-ext").default;
  const envify = require("envify/custom");

  const path = require("path");
  const distPath = path.resolve(process.cwd(), "dist");

  // load all plugins in "devDependencies" into the variable $
  const $ = require("gulp-load-plugins")({
    pattern: ["*"],
    scope: ["devDependencies"]
  });

  const onError = err => {
    $.util.log($.util.colors.bgRed($.util.colors.white(err)));
  };

  const logUpdate = msg => {
github hensm / fx_cast / ext / bin / build.js View on Github external
"use strict";

const fs = require("fs-extra");
const path = require("path");
const minimist = require("minimist");
const webpack = require("webpack");
const webExt = require("web-ext").default;

const { ROOT
      , INCLUDE_PATH
      , DIST_PATH
      , UNPACKED_PATH } = require("./lib/paths");

const packageMeta = require(`${ROOT}/../package.json`);
const extPackageMeta = require(`${ROOT}/package.json`);
const appPackageMeta = require(`${ROOT}/../app/package.json`);


const argv = minimist(process.argv.slice(2), {
    boolean: [ "package", "watch" ]
  , string: [ "mirroringAppId", "mode" ]
  , default: {
        package: false                                  // Should package with web-ext
github soapdog / patchfox / gulpfile.js View on Github external
/* eslint-env node */
"use strict";

const { series, parallel, src, dest, watch } = require("gulp");
const browserify = require("browserify");
const source = require("vinyl-source-stream");
const buffer = require("vinyl-buffer");
const log = require("gulplog");
const sourcemaps = require("gulp-sourcemaps");
const webExt = require("web-ext").default;
const path = require("path");
const bulkify = require("bulkify");
const del = require("del");
const through = require("through2");
const globby = require("globby");
const sass = require("gulp-sass");

let extensionRunner = {};

// The `clean` function is not exported so it can be considered a private task.
// It can still be used within the `series()` composition.
function clean() {
    return del([
        "debug/**",
        "!debug"
    ]);
github treosh / exthouse / src / utils / measure-firefox.js View on Github external
// @ts-nocheck
const webExt = require('web-ext').default
const getPort = require('get-port')
const PP_FF = require('puppeteer-firefox')

/**
 * @typedef {import('../index').Extension} Extension
 *
 * @param {string} url
 * @param {Extension} ext
 * @return {Promise<{ lhr: {audits: Object} }>}
 */

exports.measureFirefox = async function(url, ext) {
  let extensionRunners
  let browser

  if (ext.path) {
github cliqz-oss / browser-core / tests / runners / launchers / firefox-web-ext.js View on Github external
firefox: firefoxPath,
      noReload: true,
      sourceDir,
      artifactsDir: sourceDir,
      startUrl: getOptionsUrl(),
      keepProfileChanges,
      firefoxProfile,
      pref: {
        ...prefsFromTalos,
        'lightweightThemes.selectedThemeID': 'firefox-compact-light@mozilla.org',
        'browser.link.open_newwindow': 3,
        'dom.min_background_timeout_value': 50,
        ...this.prefs,
      },
    };
    const runner = await webExt.cmd.run(options, {
      getValidatedManifest() {
        return {
          name: '',
          version: '',
        };
      },
    });
    this.firefox = runner.firefox;
    this.reloadAllExtensions = runner.reloadAllExtensions.bind(runner);
  }
github mozilla-lockwise / lockwise-addon / test / integration / driver.js View on Github external
async initialize() {
    if (this.webext) {
      return this.webext;
    }

    const sourceDir = PATH.dirname(this.manifest);
    const artifactsDir = PATH.resolve(sourceDir, "../addons");
    const info = await WebExtUtil.cmd.build({
      sourceDir,
      artifactsDir,
      overwriteDest: true,
    });

    this.webext = info;

    return this;
  }

web-ext

A command line tool to help build, run, and test web extensions

MPL-2.0
Latest version published 3 months ago

Package Health Score

79 / 100
Full package analysis