main.bat
1 @echo off 2 color 0a 3 title 360 Extension for Chrome Download 1.0 4 pushd "%~dp0" 5 6 SETLOCAL ENABLEEXTENSIONS 7 SETLOCAL ENABLEDELAYEDEXPANSION 8 9 rem Note: Do not include a backslash at the end. 10 rem set SAVE_DIR=C:UsersAdministratorDownloads 11 set SAVE_DIR=C:.Lab 1 12 set WGET_APP=C:Program Files (x86)GnuWin32inwget.exe 13 set TMP_FILE=.matched.tmp 14 15 rem 键入扩展的编号 16 :ENTER_EXTID 17 set EXT_ID= 18 rem e.g. dogkpdfcklifaemcdfbildhcofnopogp 19 set /p EXT_ID=Enter extid: 20 if "%EXT_ID%" equ "" ( 21 call :FN_BLOCKING 22 goto :ENTER_EXTID 23 ) 24 rem 手动拼接扩展页面的URL 25 set EXT_PAGE=https://ext.chrome.360.cn/webstore/detail/%EXT_ID% 26 rem 下载扩展页面文件 27 "%WGET_APP%" --no-check-certificate -q -N -P"%SAVE_DIR%" %EXT_PAGE% 28 if not exist "%SAVE_DIR%\%EXT_ID%" ( 29 echo Download failed! 30 goto :NORMAL_EXIT 31 ) 32 rem crx文件下载地址的开头 33 set MATCH_STR=var __initData 34 set MATCH_LINE= 35 rem 提取整行内容 36 findstr /c:"%MATCH_STR%" "%SAVE_DIR%\%EXT_ID%" > "%TMP_FILE%" 37 rem 解析crx文件下载地址 38 set /a POS_BEGIN=0 39 for /f "usebackq tokens=*" %%i in (`esft -p filename "%TMP_FILE%"`) do ( 40 set /a POS_BEGIN=%%i + 11 41 ) 42 set /a POS_END=0 43 for /f "usebackq tokens=*" %%i in (`esft -p .crx "%TMP_FILE%"`) do ( 44 set /a POS_END=%%i + 4 45 ) 46 set /a POS_LEN=%POS_END% - %POS_BEGIN% 47 set DL_EMBRYO= 48 for /f "usebackq tokens=*" %%i in (`esft -e %POS_BEGIN% %POS_LEN% "%TMP_FILE%"`) do ( 49 set DL_EMBRYO=%%i 50 ) 51 set DL_FINAL= 52 for /f "usebackq tokens=*" %%i in (`sr "\" "" "%DL_EMBRYO%"`) do ( 53 set DL_FINAL=%%i 54 ) 55 "%WGET_APP%" --no-check-certificate -q -N -P"%SAVE_DIR%" %DL_FINAL% 56 echo Completed. 57 if exist "%TMP_FILE%" del "%TMP_FILE%" 58 59 goto :NORMAL_EXIT 60 61 :NORMAL_EXIT 62 popd 63 pause 64 exit 65 66 67 68 @rem ##############################FBP Begin 69 @title Function Batch Program 1.0 70 @color 0a 71 @echo Note: I can't run independently. 72 @ping /n 3 127.0.0.1 > nul 73 @exit 74 75 rem eg. call :FN_BLOCKING 76 :FN_BLOCKING 77 choice /t 1 /c O /cs /d O /n 78 cls 79 goto :EOF 80 @rem ##############################FBP End