Skip to content

Commit

Permalink
format script
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingxyk committed Aug 2, 2024
1 parent 3b804f6 commit edb88fa
Show file tree
Hide file tree
Showing 19 changed files with 147 additions and 210 deletions.
10 changes: 6 additions & 4 deletions experimental-features/v2/tools/use-advanced.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

set -exu

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

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

mkdir -p ${__ROOT__}/var/tmp/v2/js/


test -f ${__ROOT__}/var/tmp/v2/js/background-default.js || cp -f ${__ROOT__}/extension-v2/js/background.js ${__ROOT__}/var/tmp/v2/js/background-default.js

cp -f ${__ROOT__}/experimental-features/v2/js/background-advance.js ${__ROOT__}/extension-v2/js/background.js
cp -f ${__ROOT__}/experimental-features/v2/js/background-advance.js ${__ROOT__}/extension-v2/js/background.js
10 changes: 6 additions & 4 deletions experimental-features/v2/tools/use-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

set -exu

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

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

mkdir -p ${__ROOT__}/var/tmp/v2/js/


test -f ${__ROOT__}/var/tmp/v2/js/background-default.js && cp -f ${__ROOT__}/var/tmp/v2/js/background-default.js ${__ROOT__}/extension-v2/js/background.js
test -f ${__ROOT__}/var/tmp/v2/js/background-default.js && cp -f ${__ROOT__}/var/tmp/v2/js/background-default.js ${__ROOT__}/extension-v2/js/background.js
1 change: 0 additions & 1 deletion experimental-features/v3/tools/update-auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ __ROOT__=$(
)
echo ${__ROOT__}


cd ${__ROOT__}/rules/example-advance/

if test -f auth.json; then
Expand Down
11 changes: 5 additions & 6 deletions experimental-features/v3/tools/update-domain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ __ROOT__=$(
)
echo ${__ROOT__}


cd ${__ROOT__}/rules/example-advance/

if test -f auth.json; then
des_line_number=$(grep -n 'requestDomains' auth.json | awk -F ":" '{print $1}')
current_value=$(sed -n "${des_line_number}p" auth.json )
current_value=$(echo $current_value | sed 's/[\s|\t|\"]//g')
current_value=$(sed -n "${des_line_number}p" auth.json)
current_value=$(echo $current_value | sed 's/[\s|\t|\"]//g')
# 字符串截取模式匹配
current_value=${current_value#requetDomain}
current_value=${current_value#: [}
Expand All @@ -28,9 +27,9 @@ if test -f auth.json; then

new_value='proxy.domain-example.com'

nums=`grep -rl "$current_value" *.json | wc -l`
if test $nums -gt 0 ; then
sed -i "s/${current_value}/${new_value}/g" `grep -rl "$current_value" *.json `
nums=$(grep -rl "$current_value" *.json | wc -l)
if test $nums -gt 0; then
sed -i "s/${current_value}/${new_value}/g" $(grep -rl "$current_value" *.json)
fi

fi
Expand Down
2 changes: 0 additions & 2 deletions experimental-features/v3/tools/update-punycode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ echo ${__ROOT__}
# 交互式
# CHARSET=UTF-8 idn --punycode-encode


old_punycode='_xn--3px_'

new_punycode='_xn--fiq_'


nums=$(grep -rl "$old_punycode" ${__ROOT__}/rules/example-advance/*.json | wc -l)

if test $nums -gt 0; then
Expand Down
20 changes: 4 additions & 16 deletions release-archive-v3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ cd ${__PROJECT__}
mkdir -p ${__PROJECT__}/var/
mkdir -p ${__PROJECT__}/dist/



## 打包 chromium 扩展

test -f ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-chromium.zip && rm -f ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-chromium.zip
Expand Down Expand Up @@ -44,14 +42,10 @@ zip -r ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-chromium.zip . \

cd ${__PROJECT__}


zip -u ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-chromium.zip ./README.md
zip -u ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-chromium.zip ./Privacy.md
zip -u ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-chromium.zip ./LICENSE




## 打包 firefox 扩展

test -f ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-firefox.zip && rm -f ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-firefox.zip
Expand All @@ -60,20 +54,16 @@ test -d ${__PROJECT__}/var/extension-tmp/ && rm -rf ${__PROJECT__}/var/extension

mkdir -p ${__PROJECT__}/var/extension-tmp/rules/

cp -rf ${__PROJECT__}/extension/rules/*.json ${__PROJECT__}/var/extension-tmp/rules/
cp -rf ${__PROJECT__}/extension/icons ${__PROJECT__}/var/extension-tmp/
cp -rf ${__PROJECT__}/extension/background-page.html ${__PROJECT__}/var/extension-tmp/
cp -rf ${__PROJECT__}/extension/js/ ${__PROJECT__}/var/extension-tmp/js/


cp -rf ${__PROJECT__}/extension/rules/*.json ${__PROJECT__}/var/extension-tmp/rules/
cp -rf ${__PROJECT__}/extension/icons ${__PROJECT__}/var/extension-tmp/
cp -rf ${__PROJECT__}/extension/background-page.html ${__PROJECT__}/var/extension-tmp/
cp -rf ${__PROJECT__}/extension/js/ ${__PROJECT__}/var/extension-tmp/js/

rm -f ${__PROJECT__}/var/extension-tmp/rules/rules_remove_content_security_policy_header_test.json
rm -f ${__PROJECT__}/var/extension-tmp/rules/rules-default-domains-helper.json

python3 tools/update-v3-manifest.py firefox



cd ${__PROJECT__}/var/extension-tmp/
zip -r ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-firefox.zip .

Expand All @@ -83,11 +73,9 @@ zip -u ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-firefox.zip ./README.md
zip -u ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-firefox.zip ./Privacy.md
zip -u ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-firefox.zip ./LICENSE


# 为了兼容 上一版的打包结果
cp -f ${__PROJECT__}/dist/ReplaceGoogleCDN-v3-chromium.zip ${__PROJECT__}/dist/ReplaceGoogleCDN-v3.zip


# 查看打包结果
cd ${__PROJECT__}/dist/

Expand Down
9 changes: 4 additions & 5 deletions tools/chromium-auto-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ __PROJECT__=$(

cd ${__DIR__}


# 自动测试
# 浏览器日志位于 nohup.out 文件

Expand All @@ -26,7 +25,7 @@ curl http://localhost:9222/json/protocol
curl http://localhost:9222/json/version

exit 0
curl http://127.0.0.1:9222/json/new?https://stackoverflow.com/tags/socat/hot?filter=all
curl http://127.0.0.1:9222/json/new?https://patrickhlauke.github.io/recaptcha/
curl http://127.0.0.1:9222/json/new?https://cdn.jsdelivr.net/
curl http://127.0.0.1:9222/json/new?https://developers.google.com/
curl http://127.0.0.1:9222/json/new?https://stackoverflow.com/tags/socat/hot?filter=all
curl http://127.0.0.1:9222/json/new?https://patrickhlauke.github.io/recaptcha/
curl http://127.0.0.1:9222/json/new?https://cdn.jsdelivr.net/
curl http://127.0.0.1:9222/json/new?https://developers.google.com/
52 changes: 18 additions & 34 deletions tools/chromium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,20 @@ HEADLESS_MODE=''
while [ $# -gt 0 ]; do
case "$1" in
--xvfb)
XVFB_COMMAND='xvfb-run --auto-servernum -e /dev/stdout -s "-terminate -screen 0 1920x1080x24" '
XVFB_COMMAND='xvfb-run --auto-servernum -e /dev/stdout -s "-terminate -screen 0 1920x1080x24" '
;;
--xwfb)
XVFB_COMMAND='xwfb-run '
XVFB_COMMAND='xwfb-run '
;;
--headless)
HEADLESS_MODE='--headless --disable-gpu '
;;
*)
HEADLESS_MODE='--headless --disable-gpu '
;;
*) ;;

esac
shift $(($# > 0 ? 1 : 0))
done


OS=$(uname -s)
ARCH=$(uname -m)
echo "$OS"
Expand All @@ -46,22 +45,22 @@ CHROMIUM=''

case $OS in
"Linux")
UUID=$(cat /proc/sys/kernel/random/uuid)
CHROMIUM='chrome-linux/chrome'
UUID=$(cat /proc/sys/kernel/random/uuid)
CHROMIUM='chrome-linux/chrome'
;;
"Darwin")
UUID=$(uuidgen)
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'
# 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'
;;
*)
echo 'current script no support !'
exit 0
;;
*)
echo 'current script no support !'
exit 0
;;
esac

test -d /tmp/${UUID} || mkdir -p /tmp/${UUID}
Expand All @@ -74,8 +73,7 @@ cd ${__PROJECT__}/var
#扩展所在目录
extensions=${__PROJECT__}/extension


cat > run-chromium.sh <<EOF
cat >run-chromium.sh <<EOF
#!/usr/bin/env bash
set -x
${XVFB_COMMAND} ${__PROJECT__}/var/${CHROMIUM} \
Expand All @@ -91,21 +89,10 @@ ${XVFB_COMMAND} ${__PROJECT__}/var/${CHROMIUM} \
about:blank
EOF


bash run-chromium.sh










exit 0


# chrome://version
# 全屏
# --start-fullscreen
Expand All @@ -130,8 +117,7 @@ exit 0
# --disable-extensions-except=
# --auto-open-devtools-for-tabs


:<<'EOF'
: <<'EOF'
MACOS chrome 硬解 HEVC
添加下面这个启动参数就可以了 open /Applications/Google\ Chrome.app --args --enable-features=PlatformHEVCDecoderSupport
Expand All @@ -141,7 +127,6 @@ EOF
# webrtc 监测
# chrome://webrtc-internals/


# 浏览器使用pac代理
# chromium --proxy-pac-url="http://localhost:8000/proxy.pac"

Expand All @@ -151,7 +136,6 @@ EOF
# 浏览器使用socks5代理
# chromium --proxy-server="socks5://127.0.0.1:1080" --host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE 127.0.0.1"


# mac 上启动chromium
# "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --flag-switches-begin --flag-switches-end -enable-logging=stderr --v=1

Expand Down
13 changes: 4 additions & 9 deletions tools/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ cd ${__PROJECT__}

test -d ${__PROJECT__}/../ReplaceGoogleCDN-v3 && rm -rf ${__PROJECT__}/../ReplaceGoogleCDN-v3

mv ${__PROJECT__}/dist/ReplaceGoogleCDN-v3 ${__PROJECT__}/../




mv ${__PROJECT__}/dist/ReplaceGoogleCDN-v3 ${__PROJECT__}/../

exit 0

Expand All @@ -36,11 +32,10 @@ cd ${__PROJECT__}
key=/home/username/key.pem
domain=chromium-extensions.jingjingxyk.com

rsync -az -r -z -v -e "ssh -p 22 -i $key" --delete ${__ROOT__}/dist/ReplaceGoogleCDN-v2.zip root@${domain}:/data/webspace/chromium-extensions/ReplaceGoogleCDN-v2.zip
rsync -az -r -z -v -e "ssh -p 22 -i $key" --delete ${__ROOT__}/dist/ReplaceGoogleCDN-v3.zip root@${domain}:/data/webspace/chromium-extensions/ReplaceGoogleCDN-v3.zip

rsync -az -r -z -v -e "ssh -p 22 -i $key" --delete ${__ROOT__}/dist/ReplaceGoogleCDN-v2.zip root@${domain}:/data/webspace/chromium-extensions/ReplaceGoogleCDN-v2.zip
rsync -az -r -z -v -e "ssh -p 22 -i $key" --delete ${__ROOT__}/dist/ReplaceGoogleCDN-v3.zip root@${domain}:/data/webspace/chromium-extensions/ReplaceGoogleCDN-v3.zip

:<<'EOF'
: <<'EOF'
scp -P 22 -i $key -v -C \
-o StrictHostKeyChecking=no \
Expand Down
3 changes: 0 additions & 3 deletions tools/download-chromium-extension.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ __PROJECT__=$(
## 下载命令例子:
# bash tools/download-chromium-extension.sh --proxy http://127.0.0.1:8015


while [ $# -gt 0 ]; do
case "$1" in
--proxy)
Expand All @@ -47,7 +46,6 @@ done
mkdir -p chromium-extensions
cd ${__PROJECT__}/var/chromium-extensions


# Clear Site Data
extension_id=aihgofjefdlhpnmeakpnjjeajofpcbhj
file_name='Clear-Site-Data'
Expand Down Expand Up @@ -75,4 +73,3 @@ unzip -d ${file_name} "${file_name}.crx"
set -e

cd ${__PROJECT__}/var/chromium-extensions

Loading

0 comments on commit edb88fa

Please sign in to comment.