2022-09-06 19:47:52 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# This script assumes a linux environment
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2022-09-19 17:08:34 +02:00
|
|
|
echo "*** uBOLite.mv3: Creating extension"
|
2022-09-06 19:47:52 +02:00
|
|
|
|
2023-04-07 16:19:43 +02:00
|
|
|
PLATFORM="chromium"
|
2022-09-07 16:15:36 +02:00
|
|
|
|
2023-04-07 16:19:43 +02:00
|
|
|
for i in "$@"; do
|
|
|
|
case $i in
|
|
|
|
quick)
|
|
|
|
QUICK="yes"
|
|
|
|
shift # past argument=value
|
|
|
|
;;
|
2023-04-07 19:24:57 +02:00
|
|
|
full)
|
|
|
|
FULL="yes"
|
|
|
|
shift # past argument=value
|
|
|
|
;;
|
2023-04-07 16:19:43 +02:00
|
|
|
firefox)
|
|
|
|
PLATFORM="firefox"
|
|
|
|
shift # past argument=value
|
|
|
|
;;
|
|
|
|
chromium)
|
|
|
|
PLATFORM="chromium"
|
|
|
|
shift # past argument=value
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
DES="dist/build/uBOLite.$PLATFORM"
|
|
|
|
|
|
|
|
if [ "$QUICK" != "yes" ]; then
|
2022-09-07 16:15:36 +02:00
|
|
|
rm -rf $DES
|
|
|
|
fi
|
|
|
|
|
2022-09-06 19:47:52 +02:00
|
|
|
mkdir -p $DES
|
|
|
|
cd $DES
|
|
|
|
DES=$(pwd)
|
|
|
|
cd - > /dev/null
|
|
|
|
|
2022-09-07 16:15:36 +02:00
|
|
|
mkdir -p $DES/css/fonts
|
|
|
|
mkdir -p $DES/js
|
|
|
|
mkdir -p $DES/img
|
2022-09-06 19:47:52 +02:00
|
|
|
|
2023-08-25 17:17:15 +02:00
|
|
|
if [ -n "$UBO_VERSION" ]; then
|
2023-08-11 19:22:25 +02:00
|
|
|
UBO_REPO="https://github.com/gorhill/uBlock.git"
|
|
|
|
UBO_DIR=$(mktemp -d)
|
|
|
|
echo "*** uBOLite.mv3: Fetching uBO $UBO_VERSION from $UBO_REPO into $UBO_DIR"
|
2023-08-19 14:50:20 +02:00
|
|
|
cd "$UBO_DIR"
|
|
|
|
git init -q
|
|
|
|
git remote add origin "https://github.com/gorhill/uBlock.git"
|
|
|
|
git fetch --depth 1 origin "$UBO_VERSION"
|
|
|
|
git checkout -q FETCH_HEAD
|
2023-08-19 15:15:15 +02:00
|
|
|
cd - > /dev/null
|
2023-08-11 19:22:25 +02:00
|
|
|
else
|
|
|
|
UBO_DIR=.
|
|
|
|
fi
|
2023-08-10 19:08:15 +02:00
|
|
|
|
2022-09-19 17:08:34 +02:00
|
|
|
echo "*** uBOLite.mv3: Copying common files"
|
2023-08-10 19:08:15 +02:00
|
|
|
cp -R $UBO_DIR/src/css/fonts/* $DES/css/fonts/
|
|
|
|
cp $UBO_DIR/src/css/themes/default.css $DES/css/
|
|
|
|
cp $UBO_DIR/src/css/common.css $DES/css/
|
|
|
|
cp $UBO_DIR/src/css/dashboard-common.css $DES/css/
|
|
|
|
cp $UBO_DIR/src/css/fa-icons.css $DES/css/
|
2022-09-13 23:44:24 +02:00
|
|
|
|
2023-08-10 19:08:15 +02:00
|
|
|
cp $UBO_DIR/src/js/dom.js $DES/js/
|
|
|
|
cp $UBO_DIR/src/js/fa-icons.js $DES/js/
|
|
|
|
cp $UBO_DIR/src/js/i18n.js $DES/js/
|
|
|
|
cp $UBO_DIR/src/lib/punycode.js $DES/js/
|
2022-09-07 16:15:36 +02:00
|
|
|
|
2023-08-10 19:08:15 +02:00
|
|
|
cp -R $UBO_DIR/src/img/flags-of-the-world $DES/img
|
2023-06-11 15:20:10 +02:00
|
|
|
|
2022-09-06 19:47:52 +02:00
|
|
|
cp LICENSE.txt $DES/
|
|
|
|
|
2022-09-19 17:08:34 +02:00
|
|
|
echo "*** uBOLite.mv3: Copying mv3-specific files"
|
2023-04-07 16:19:43 +02:00
|
|
|
if [ "$PLATFORM" = "firefox" ]; then
|
|
|
|
cp platform/mv3/firefox/background.html $DES/
|
|
|
|
fi
|
2022-09-07 16:15:36 +02:00
|
|
|
cp platform/mv3/extension/*.html $DES/
|
2023-06-13 17:40:41 +02:00
|
|
|
cp platform/mv3/extension/*.json $DES/
|
2022-09-07 16:15:36 +02:00
|
|
|
cp platform/mv3/extension/css/* $DES/css/
|
2022-10-15 19:05:20 +02:00
|
|
|
cp -R platform/mv3/extension/js/* $DES/js/
|
2022-09-07 16:15:36 +02:00
|
|
|
cp platform/mv3/extension/img/* $DES/img/
|
2022-09-13 23:44:24 +02:00
|
|
|
cp -R platform/mv3/extension/_locales $DES/
|
2023-08-12 14:00:59 +02:00
|
|
|
cp platform/mv3/README.md $DES/
|
2022-09-07 16:15:36 +02:00
|
|
|
|
2023-04-07 16:19:43 +02:00
|
|
|
if [ "$QUICK" != "yes" ]; then
|
2022-09-19 17:08:34 +02:00
|
|
|
echo "*** uBOLite.mv3: Generating rulesets"
|
2022-09-07 16:15:36 +02:00
|
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
mkdir -p $TMPDIR
|
2023-04-07 16:19:43 +02:00
|
|
|
if [ "$PLATFORM" = "chromium" ]; then
|
|
|
|
cp platform/mv3/chromium/manifest.json $DES/
|
|
|
|
elif [ "$PLATFORM" = "firefox" ]; then
|
|
|
|
cp platform/mv3/firefox/manifest.json $DES/
|
|
|
|
fi
|
2022-09-07 16:15:36 +02:00
|
|
|
./tools/make-nodejs.sh $TMPDIR
|
|
|
|
cp platform/mv3/package.json $TMPDIR/
|
|
|
|
cp platform/mv3/*.js $TMPDIR/
|
2022-09-20 14:24:01 +02:00
|
|
|
cp platform/mv3/extension/js/utils.js $TMPDIR/js/
|
2023-08-10 19:16:35 +02:00
|
|
|
cp $UBO_DIR/assets/assets.json $TMPDIR/
|
|
|
|
cp $UBO_DIR/assets/resources/scriptlets.js $TMPDIR/
|
2022-09-16 21:56:35 +02:00
|
|
|
cp -R platform/mv3/scriptlets $TMPDIR/
|
2022-10-16 18:05:24 +02:00
|
|
|
mkdir -p $TMPDIR/web_accessible_resources
|
2023-08-10 19:08:15 +02:00
|
|
|
cp $UBO_DIR/src/web_accessible_resources/* $TMPDIR/web_accessible_resources/
|
2022-09-07 16:15:36 +02:00
|
|
|
cd $TMPDIR
|
2023-04-07 16:19:43 +02:00
|
|
|
node --no-warnings make-rulesets.js output=$DES platform="$PLATFORM"
|
2022-09-07 16:15:36 +02:00
|
|
|
cd - > /dev/null
|
|
|
|
rm -rf $TMPDIR
|
|
|
|
fi
|
2022-09-06 19:47:52 +02:00
|
|
|
|
2022-09-19 17:08:34 +02:00
|
|
|
echo "*** uBOLite.mv3: extension ready"
|
2022-09-06 19:47:52 +02:00
|
|
|
echo "Extension location: $DES/"
|
|
|
|
|
2023-04-07 19:24:57 +02:00
|
|
|
if [ "$FULL" = "yes" ]; then
|
2023-04-07 19:34:27 +02:00
|
|
|
EXTENSION="zip"
|
|
|
|
if [ "$PLATFORM" = "firefox" ]; then
|
|
|
|
EXTENSION="xpi"
|
|
|
|
fi
|
2023-04-07 19:24:57 +02:00
|
|
|
echo "*** uBOLite.mv3: Creating publishable package..."
|
2023-04-07 19:34:27 +02:00
|
|
|
PACKAGENAME="uBOLite_$(jq -r .version $DES/manifest.json).$PLATFORM.mv3.$EXTENSION"
|
2022-09-07 16:23:40 +02:00
|
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
mkdir -p $TMPDIR
|
|
|
|
cp -R $DES/* $TMPDIR/
|
|
|
|
cd $TMPDIR > /dev/null
|
2022-09-15 19:37:39 +02:00
|
|
|
zip $PACKAGENAME -qr ./*
|
2022-09-07 16:23:40 +02:00
|
|
|
cd - > /dev/null
|
2022-09-08 17:44:27 +02:00
|
|
|
cp $TMPDIR/$PACKAGENAME dist/build/
|
2022-09-07 16:23:40 +02:00
|
|
|
rm -rf $TMPDIR
|
2022-09-08 17:21:39 +02:00
|
|
|
echo "Package location: $(pwd)/dist/build/$PACKAGENAME"
|
2022-09-07 16:23:40 +02:00
|
|
|
fi
|