Closed ghost closed 2 years ago
Looks good, i would make it as loop because there is lots of dupliacted code. So that you can specify list of ids of extensions that will be installed.
EDIT: Something like:
EXTENSIONS=(
cjpalhdlnbpafiamejdnhcphjbkeiagm # ublock
mnjggcdmjocbbbhaepdhchncahnbgone # sponsorblock
)
for EXT_ID in "${EXTENSIONS[@]}"
do
EXT_URL="https://clients2.google.com/service/update2/crx?response=redirect&nacl_arch=x86-64&prodversion=${CHROMIUM_VERSION}&acceptformat=crx2,crx3&x=id%3D${EXT_ID}%26installsource%3Dondemand%26uc"
EXT_PATH="${EXTENSIONS_DIR}/${EXT_ID}.crx"
echo "Installing extension $EXT_ID from $EXT_URL to $EXT_PATH"
wget -O "${EXT_PATH}" "${EXT_URL}"
EXT_VERSION="$(unzip -p "${EXT_PATH}" manifest.json 2>/dev/null | jq -r ".version")";
echo -e "{\n \"external_crx\": \"${EXT_PATH}\"\n \"external_version\": \"${EXT_VERSION}\"\n}" > "${EXTENSIONS_DIR}/${EXT_ID}.json";
done
@m1k1o Good idea! Just finished rewriting my pull request.
@m1k1o FYI, the default Dockerfile shell is /bin/sh
, which doesn't support arrays. That's why I changed it to /bin/bash
using the SHELL instruction.
I am trying it right now, mkdir -p ${EXTENSIONS_DIR};
seems to be missing. And even after adding that I don'ŧ see extensions in the browser. I am gonna try again...
@whalehub there is missing ,
in extensions json, i guess thats why it fails to load.
EDIT: Yes, that fixes the issue. echo -e "{\n \"external_crx\": \"${EXT_PATH}\",\n \"external_version\": \"${EXT_VERSION}\"\n}" > "${EXTENSIONS_DIR}"/"${EXT_ID}".json; \
@m1k1o Nice catch, I can confirm that it's working now. The pull request should be good to merge.
I should have done this a long time ago, but I never got around to implementing this idea until now.