1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 11:22:38 +01:00
uBlock/tools/make-mv3.sh
Raymond Hill 232c44eeb2
[mv3] Add scriptlet support; improve reliability of cosmetic filtering
First iteration of adding scriptlet support. As with cosmetic
filtering, scriptlet niijection occurs only on sites for which
uBO Lite was granted extended permissions.

At the moment, only three scriptlets are supported:
- abort-current-script
- json-prune
- set-constant

More will be added in the future.
2022-09-16 15:56:35 -04:00

77 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# This script assumes a linux environment
set -e
echo "*** uBlock0.mv3: Creating extension"
DES="dist/build/uBlock0.mv3"
if [ "$1" != "quick" ]; then
rm -rf $DES
fi
mkdir -p $DES
cd $DES
DES=$(pwd)
cd - > /dev/null
mkdir -p $DES/css/fonts
mkdir -p $DES/js
mkdir -p $DES/img
echo "*** uBlock0.mv3: Copying common files"
cp -R src/css/fonts/* $DES/css/fonts/
cp src/css/themes/default.css $DES/css/
cp src/css/common.css $DES/css/
cp src/css/dashboard.css $DES/css/
cp src/css/dashboard-common.css $DES/css/
cp src/css/fa-icons.css $DES/css/
cp src/js/fa-icons.js $DES/js/
cp src/js/i18n.js $DES/js/
cp LICENSE.txt $DES/
echo "*** uBlock0.mv3: Copying mv3-specific files"
cp platform/mv3/extension/*.html $DES/
cp platform/mv3/extension/css/* $DES/css/
cp platform/mv3/extension/js/* $DES/js/
cp platform/mv3/extension/img/* $DES/img/
cp -R platform/mv3/extension/_locales $DES/
if [ "$1" != "quick" ]; then
echo "*** uBlock0.mv3: Generating rulesets"
TMPDIR=$(mktemp -d)
mkdir -p $TMPDIR
cp platform/mv3/extension/manifest.json $DES/
./tools/make-nodejs.sh $TMPDIR
cp platform/mv3/package.json $TMPDIR/
cp platform/mv3/*.js $TMPDIR/
cp assets/assets.json $TMPDIR/
cp -R platform/mv3/scriptlets $TMPDIR/
cd $TMPDIR
node --no-warnings make-rulesets.js output=$DES
cd - > /dev/null
rm -rf $TMPDIR
fi
echo "*** uBlock0.mv3: extension ready"
echo "Extension location: $DES/"
if [ "$1" = "full" ]; then
echo "*** uBlock0.mv3: Creating webstore package..."
PACKAGENAME=uBlock0_$(jq -r .version $DES/manifest.json).mv3.zip
TMPDIR=$(mktemp -d)
mkdir -p $TMPDIR
cp -R $DES/* $TMPDIR/
cd $TMPDIR > /dev/null
rm log.txt
zip $PACKAGENAME -qr ./*
cd - > /dev/null
cp $TMPDIR/$PACKAGENAME dist/build/
rm -rf $TMPDIR
echo "Package location: $(pwd)/dist/build/$PACKAGENAME"
fi