m1k1o / neko

A self hosted virtual browser that runs in docker and uses WebRTC.
https://neko.m1k1o.net/
Apache License 2.0
5.98k stars 449 forks source link

Install latest Ungoogled Chromium extensions at build time #183

Closed ghost closed 2 years ago

ghost commented 2 years ago

I should have done this a long time ago, but I never got around to implementing this idea until now.

m1k1o commented 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
ghost commented 2 years ago

@m1k1o Good idea! Just finished rewriting my pull request.

ghost commented 2 years ago

@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.

m1k1o commented 2 years ago

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...

m1k1o commented 2 years ago

@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; \

ghost commented 2 years ago

@m1k1o Nice catch, I can confirm that it's working now. The pull request should be good to merge.