Skip to content

Instantly share code, notes, and snippets.

View AllenFang's full-sized avatar
🇹🇼
I may be slow to respond.

allen AllenFang

🇹🇼
I may be slow to respond.
View GitHub Profile
import webdriver from 'selenium-webdriver';
import firefox from 'selenium-webdriver/firefox';
const XPI_PATH = ... // xpi file path
const firefoxOption = new firefox.Options();
firefoxOption.setPreference('xpinstall.signatures.required', false);
firefoxOption.setBinary(firefox.Channel.AURORA); // Set Developer Edition
const driver = new webdriver.Builder()
import webdriver from 'selenium-webdriver';
import { Driver, Options } from 'selenium-webdriver/chrome';
const CRX_PATH = // YOUR_LOCAL_CRX_PATH
const options = new Options();
options.addExtensions(CRX_PATH);
const driver = Driver.createSession(options);
import webdriver from 'selenium-webdriver';
import { Driver, Options } from 'selenium-webdriver/chrome';
const EXT_PATH = //YOUR_LOCAL_EXTENSION_PATH
const chromeOptions = { args: [`load-extension=${EXT_PATH}`] };
const driver = new webdriver.Builder()
.withCapabilities({ chromeOptions })
.build();
import gulpJsonTransform from 'gulp-json-transform';
function patchChunks() {
return gulp.src(path.resolve(config.output.path, 'manifest.json'))
.pipe(gulpJsonTransform((data) => {
data.background.scripts = ...
data.content_scripts = ....
// ...
return data;
}))
"background": {
"scripts": [
"js/background.d2faff93.js"
]
}
import gulpWebpack from 'webpack-stream';
import config from './config/webpack.prod.config';
function webpack() {
return gulp.src(Object.values(config.entry))
.pipe(gulpWebpack({ config }, null, (err, stats) => {
stats.compilation.chunks.forEach(({ files: assets, name }) => {
// name is chunk name
// assets is chunk file name
// persist them here!
new UglifyJSPlugin({
uglifyOptions: {
toplevel: true,
mangle: {
properties: {
regex: /REGEXS/
}
}
},
// ...
git clone https://github.com/AllenFang/lerna-tutorial-example.git
cd lerna-tutorial-example
cp ~/.ssh/id_rsa.pub ./docker/git-server/keys
cp ~/.ssh/id_rsa ./docker/git-server/keys
cd docker
docker-compose up -d
function patchManifest(done) {
const tasks = countryList.map((countryName) => {
function patchManifestByCountry() {
return
gulp.src(`./build/${countryName}/manifest.json`)
.pipe(gulpJsonTransform((data) => {
data.homepage_url = .....;
return data;
}))
.pipe(gulp.dest(`./build/${countryName}/`));
import gulp from 'gulp';
import gulpJsonTransform from 'gulp-json-transform';
import countryList from './config/countries'; // it's an array of string
// omit clean, distribute etc
function patchManifest(done) {
const tasks = countryList.map((countryName) => {
// Right here, we return a function per country
return () =>