-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
112 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: 混淆 _worker.js 文件 | ||
|
||
on: | ||
#push: | ||
#paths: | ||
#- '_worker.js' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
obfuscate: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: 使用 Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16" | ||
|
||
- name: 安装依赖 | ||
run: npm install -g javascript-obfuscator | ||
|
||
- name: 准备混淆文件 | ||
run: | | ||
if grep -q "Obfuscate-cmliu" _worker.js; then | ||
echo "检测到 Obfuscate 准备分段处理" | ||
line_number=$(awk '/Obfuscate-cmliu/ {print NR; exit}' _worker.js) | ||
echo "Obfuscate 分段处理行号为: $line_number" | ||
head -n $line_number _worker.js > src.js | ||
tail -n +$((line_number + 1)) _worker.js > index.js | ||
rm _worker.js | ||
else | ||
echo "未检测到 Obfuscate 执行全文件混淆" | ||
mv _worker.js index.js | ||
fi | ||
- name: 混淆代码 | ||
run: | | ||
javascript-obfuscator index.js --output _worker.js \ | ||
--compact true \ | ||
--control-flow-flattening true \ | ||
--control-flow-flattening-threshold 1 \ | ||
--dead-code-injection true \ | ||
--dead-code-injection-threshold 1 \ | ||
--identifier-names-generator hexadecimal \ | ||
--rename-globals true \ | ||
--string-array true \ | ||
--string-array-encoding 'rc4' \ | ||
--string-array-threshold 1 \ | ||
--transform-object-keys true \ | ||
--unicode-escape-sequence true | ||
- name: 提交更改 | ||
run: | | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git add _worker.js | ||
git commit -m "Obfuscate _worker.js" || echo "No changes to commit" | ||
- name: 推送更改到 main 分支 | ||
run: | | ||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | ||
git fetch origin | ||
git checkout main | ||
git merge --no-ff ${{ github.sha }} | ||
git push origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters