Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev tools 更新,chromium 或者 firefox 启动多实例 #189

Merged
merged 10 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions tools/chromium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,39 @@ export GOOGLE_API_KEY="no"
export GOOGLE_DEFAULT_CLIENT_ID="no"
export GOOGLE_DEFAULT_CLIENT_SECRET="no"

uuid=$(cat /proc/sys/kernel/random/uuid)
test -d /tmp/$uuid || mkdir -p /tmp/$uuid
USER_DATA=/tmp/$uuid
UUID=''
CHROMIUM=''

case $OS in
"Linux")
chromium='chrome-linux/chrome'
UUID=$(cat /proc/sys/kernel/random/uuid)
CHROMIUM='chrome-linux/chrome'
;;
"Darwin")
chromium='chrome-mac/Chromium.app/Contents/MacOS/Chromium'
UUID=$(uuidgen)
CHROMIUM='chrome-mac/Chromium.app/Contents/MacOS/Chromium'
;;
"MINGW64_NT")
# set chrome_user_data_dir='C:\Users\%username%\Local" "Settings\Temp\chrome-user-data'
# IF NOT EXIST %chrome_user_data_dir% MD %chrome_user_data_dir%
chromium='chrome-win\\chrome.exe'
CHROMIUM='chrome-win\\chrome.exe'
;;
*)
echo 'current script no support !'
;;
esac

echo $chromium
test -d /tmp/${UUID} || mkdir -p /tmp/${UUID}
USER_DATA=/tmp/${UUID}

echo ${CHROMIUM}

cd ${__PROJECT__}/var

#扩展所在目录
extensions=${__PROJECT__}/extension

$chromium \
${CHROMIUM} \
--user-data-dir=$USER_DATA \
--enable-remote-extensions \
--enable-extensions \
Expand Down Expand Up @@ -82,7 +89,7 @@ $chromium \



:<<\EOF
:<<'EOF'

MACOS chrome 硬解 HEVC
添加下面这个启动参数就可以了 open /Applications/Google\ Chrome.app --args --enable-features=PlatformHEVCDecoderSupport
Expand Down
30 changes: 26 additions & 4 deletions tools/download-firefox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cd ${__PROJECT__}/var/
# download firefox
# https://www.mozilla.org/en-US/firefox/all/#product-desktop-release

# download firefox
# show download firefox
# https://archive.mozilla.org/pub/firefox/releases/

# firefox manifest-v3-migration-guide
Expand All @@ -35,7 +35,7 @@ OS=$(uname -s)
ARCH=$(uname -m)
echo "${OS}_${ARCH}"

FIREFOX_VERSION=118.0b3
FIREFOX_VERSION=119.0b7

if [ -n "$1" ]; then
FIREFOX_VERSION="$1"
Expand All @@ -54,9 +54,28 @@ case $OS in
tar -jxvf firefox-${FIREFOX_VERSION}.tar.bz2
;;
"Darwin")
test -f Firefox%20${FIREFOX_VERSION}.dmg && rm -rf Firefox%20${FIREFOX_VERSION}.dmg
FIREFOX_DMG_FILE=Firefox%20${FIREFOX_VERSION}.dmg
test -f ${FIREFOX_DMG_FILE} && rm -rf ${FIREFOX_DMG_FILE}
DOWNLOAD_FIREFOX_URL=${DOWNLOAD_FIREFOX_URL_PREFIX}/${FIREFOX_VERSION}/mac/en-US/Firefox%20${FIREFOX_VERSION}.dmg
curl -Lo Firefox%20${FIREFOX_VERSION}.dmg ${DOWNLOAD_FIREFOX_URL}
curl -Lo ${FIREFOX_DMG_FILE} ${DOWNLOAD_FIREFOX_URL}

# brew install p7zip
# 使用 7-zip 解压
# 7z x ${FIREFOX_DMG_FILE}
# chmod a+x ${__PROJECT__}/var/Firefox/Firefox.app/Contents/MacOS/firefox

# 使用 hdiutil 挂载 DMG格式 文件
UUID=$(uuidgen)
TMP_MOUNT_POINT=/tmp/${UUID}
mkdir -p ${TMP_MOUNT_POINT}
hdiutil attach -mountpoint ${TMP_MOUNT_POINT} ${FIREFOX_DMG_FILE}
# hdiutil attach Firefox%20${FIREFOX_VERSION}.dmg

# 将应用程序拷贝到指定目录
mkdir -p ${__PROJECT__}/var/Firefox
cp -rf /private/${TMP_MOUNT_POINT}/Firefox.app ${__PROJECT__}/var/Firefox
ls -lh ${__PROJECT__}/var/Firefox/

;;

"MINGW64_NT")
Expand All @@ -65,3 +84,6 @@ case $OS in
curl -Lo Firefox%20Setup%20${FIREFOX_VERSION}.msi ${DOWNLOAD_FIREFOX_URL}
;;
esac



91 changes: 91 additions & 0 deletions tools/firefox-web-ext.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

set -exu

__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}

__PROJECT__=$(
cd ${__DIR__}/../
pwd
)

OS=$(uname -s)
ARCH=$(uname -m)
echo "$OS"

FIREFOX=''
UUID=''
case $OS in
"Linux")
UUID=$(cat /proc/sys/kernel/random/uuid)
FIREFOX=${__PROJECT__}/var/firefox/firefox
;;
"Darwin")
UUID=$(uuidgen)
# macos firefox 默认启动目录
FIREFOX='/Applications/Firefox.app/Contents/MacOS/firefox'
# 自定义 启动目录
FIREFOX="${__PROJECT__}/var/Firefox/Firefox.app/Contents/MacOS/firefox-bin"
;;
'MINGW64_NT'* | 'MSYS_NT'*)
;;
*)
echo 'current script no support !'
;;
esac


profile_folder="/tmp/${UUID}"

mkdir -p $profile_folder


mkdir -p ${__PROJECT__}/var/
cd ${__PROJECT__}/var/


# python3 ${__PROJECT__}/extension/tools/update-manifest.py firefox

# firefox web extension
# https://github.com/mdn/webextensions-examples.git

# https://wiki.mozilla.org/Firefox/CommandLineOptions

# firefox use Manifest V3
# https://extensionworkshop.com/documentation/develop/manifest-v3-migration-guide/

# declarativeNetRequestWithHostAccess 声明式网络请求
# https://github.com/mdn/webextensions-examples/blob/main/dnr-dynamic-with-options/manifest.json
# "permissions": ["declarativeNetRequestWithHostAccess"],
# "optional_host_permissions": ["*://*/"],
# "optional_permissions": ["*://*/"],

# 支持 ResourceType
# https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/ResourceType


# 它使用 user.js 中的相应设置覆盖 prefs.js 中的任何设置。
cp -f ${__PROJECT__}/tools/prefs.js $profile_folder

# 进入扩展所在目录
cd ${__PROJECT__}/extension-v2/

# reference https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#web-ext-run

npx web-ext run \
--verbose \
--firefox=${FIREFOX} \
--firefox-profile=$profile_folder \
--profile-create-if-missing \
--arg="--new-tab=https://stackoverflow.com/tags/socat/hot?filter=all" \
--start-url https://m3.material.io/

# --devtools \
# --browser-console \


exit 0
58 changes: 33 additions & 25 deletions tools/firefox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,33 @@ __PROJECT__=$(
pwd
)

uuid=$(cat /proc/sys/kernel/random/uuid)
profile_folder="/tmp/${uuid}"
OS=$(uname -s)
ARCH=$(uname -m)
echo "$OS"

FIREFOX=''
UUID=''
case $OS in
"Linux")
UUID=$(cat /proc/sys/kernel/random/uuid)
FIREFOX=${__PROJECT__}/var/firefox/firefox
;;
"Darwin")
UUID=$(uuidgen)
# macos firefox 默认启动目录
FIREFOX='/Applications/Firefox.app/Contents/MacOS/firefox'
# 自定义 启动目录
FIREFOX="${__PROJECT__}/var/Firefox/Firefox.app/Contents/MacOS/firefox-bin"
;;
'MINGW64_NT'* | 'MSYS_NT'*)
;;
*)
echo 'current script no support !'
;;
esac


profile_folder="/tmp/${UUID}"

mkdir -p $profile_folder

Expand All @@ -23,7 +48,7 @@ mkdir -p ${__PROJECT__}/var/
cd ${__PROJECT__}/var/


python3 ${__PROJECT__}/extension/tools/update-manifest.py firefox
# python3 ${__PROJECT__}/extension/tools/update-manifest.py firefox

# firefox web extension
# https://github.com/mdn/webextensions-examples.git
Expand All @@ -46,28 +71,9 @@ python3 ${__PROJECT__}/extension/tools/update-manifest.py firefox
# 它使用 user.js 中的相应设置覆盖 prefs.js 中的任何设置。
cp -f ${__PROJECT__}/tools/prefs.js $profile_folder

# 启动firefox 实例

cd ${__PROJECT__}/extension/

# reference https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#web-ext-run

npx web-ext run \
--verbose \
--firefox=${__PROJECT__}/var/firefox/firefox \
--firefox-profile=$profile_folder \
--profile-create-if-missing \
--arg="--new-tab=https://stackoverflow.com/tags/socat/hot?filter=all" \
--start-url https://m3.material.io/

# --devtools \
# --browser-console \


exit 0

# export MOZ_ENABLE_WAYLAND=1

./firefox/firefox \
${FIREFOX} \
-profile "$profile_folder" \
-start-debugger-server 9221 \
--remote-debugging-port 9222 \
Expand All @@ -80,9 +86,11 @@ exit 0
# -jsconsole \
# about:blank

# 此命令已不可用 ; Firefox 允许通过 RDP(远程调试协议)安装插件
# 此命令已不可用
# -install-global-extension ${__ROOT__}/extension-v2 \
# -install-global-extension ${__DIR__}/traduzir_paginas_web-9.8.1.0.xpi \

# 新版Firefox 允许通过 RDP(远程调试协议)安装插件
# gecko-dev
# https://github.com/mozilla/gecko-dev.git

Loading