From 2ec777f8d54c31340c2ff30af6d08a41f7002fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=E1=BA=BF=20H=C6=B0ng?= Date: Thu, 19 Jun 2025 23:25:30 +0700 Subject: [PATCH] chore: what the fuck --- README.md | 3 ++- apps/ws-scrcpy/README.md | 7 +++++-- games/ys/.python-version | 1 + games/ys/README.md | 0 games/ys/hello.py | 6 ++++++ games/ys/pyproject.toml | 9 +++++++++ games/ys/settings_dumper.py | 8 ++++++++ games/ys/uv.lock | 29 +++++++++++++++++++++++++++++ os/android/backup.sh | 23 +++++++++++++++++++++++ os/android/restore.sh | 15 +++++++++++++++ 10 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 games/ys/.python-version create mode 100644 games/ys/README.md create mode 100644 games/ys/hello.py create mode 100644 games/ys/pyproject.toml create mode 100644 games/ys/settings_dumper.py create mode 100644 games/ys/uv.lock create mode 100644 os/android/backup.sh create mode 100644 os/android/restore.sh diff --git a/README.md b/README.md index 3dfd21c..4db360e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ Scripts I created for personal use. + [apps](./apps/): Scripts for specific applications. + [games](./apps/): Scripts for specific games. -+ [userscripts](./userscripts/): UserScripts for specific web pages. ++ [os](./os/): Scripts for specific OSes. ++ ~~[userscripts](./userscripts/): UserScripts for specific web pages.~~ See https://github.com/teppyboy/userscripts for updated scripts. + [userstyles](./userstyles/): UserStyles (or sometimes plain CSS) for specific web pages. + [web](./web/): Scripts meant to be executed in Console for specific web pages. diff --git a/apps/ws-scrcpy/README.md b/apps/ws-scrcpy/README.md index e48b5ff..afe6593 100644 --- a/apps/ws-scrcpy/README.md +++ b/apps/ws-scrcpy/README.md @@ -8,7 +8,7 @@ - ~~YOU ALSO NEED TO OPEN ADB WIRELESS IN DEVELOPER SETTINGS FOR THIS TO WORK~~ (The script can use `su` to start ADB wireless now) - You need to grant Termux:API full Location permission and set to "Always" (Foreground mode will not work correctly) - Rootless mode is available, although you'll have to start the ADB server yourself. -- Dependencies: `root-repo` `tsu` `moreutils` `build-essential` `nodejs` `python3` `android-tools` `git` `termux-api` +- Dependencies: `root-repo` `tsu` `moreutils` `build-essential` `nodejs-lts` `python3` `android-tools` `git` `termux-api` > Or execute `pkg install root-repo tsu moreutils build-essential nodejs python3 android-tools git termux-api` @@ -20,7 +20,9 @@ git clone https://github.com/NetrisTV/ws-scrcpy cd ./ws-scrcpy export GYP_DEFINES="android_ndk_path=''" +npm install -g node-gyp npm install +# Ignore errors about puppeteer in unsupported platform, it'll work just fine. ``` 1. Download ws-scrcpy-launcher.py: @@ -51,12 +53,13 @@ Then after that you can launch ws-scrcpy as explained above. > > ```shell > pkg update -> pkg install root-repo moreutils build-essential nodejs python3 android-tools git termux-api +> pkg install root-repo moreutils build-essential nodejs-lts python3 android-tools git termux-api > pkg install tsu > cd ~ > git clone https://github.com/NetrisTV/ws-scrcpy > cd ./ws-scrcpy > export GYP_DEFINES="android_ndk_path=''" +> npm install -g node-gyp > npm install > cd .. > curl -OL https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/apps/ws-scrcpy/ws-scrcpy-launcher.py diff --git a/games/ys/.python-version b/games/ys/.python-version new file mode 100644 index 0000000..2c07333 --- /dev/null +++ b/games/ys/.python-version @@ -0,0 +1 @@ +3.11 diff --git a/games/ys/README.md b/games/ys/README.md new file mode 100644 index 0000000..e69de29 diff --git a/games/ys/hello.py b/games/ys/hello.py new file mode 100644 index 0000000..bdd0b83 --- /dev/null +++ b/games/ys/hello.py @@ -0,0 +1,6 @@ +def main(): + print("Hello from ys!") + + +if __name__ == "__main__": + main() diff --git a/games/ys/pyproject.toml b/games/ys/pyproject.toml new file mode 100644 index 0000000..4f548f5 --- /dev/null +++ b/games/ys/pyproject.toml @@ -0,0 +1,9 @@ +[project] +name = "ys" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.11" +dependencies = [ + "pywin32>=308", +] diff --git a/games/ys/settings_dumper.py b/games/ys/settings_dumper.py new file mode 100644 index 0000000..06c86da --- /dev/null +++ b/games/ys/settings_dumper.py @@ -0,0 +1,8 @@ +import json +import win32api +import win32con + +ys_hkey = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER, "Software\\miHoYo\\Genshin Impact", 0, win32con.KEY_ALL_ACCESS) +data_bytes = win32api.RegQueryValueEx(ys_hkey, "GENERAL_DATA_h2389025596")[0] +data = json.loads(data_bytes[:-1]) +print(data) \ No newline at end of file diff --git a/games/ys/uv.lock b/games/ys/uv.lock new file mode 100644 index 0000000..5eddc63 --- /dev/null +++ b/games/ys/uv.lock @@ -0,0 +1,29 @@ +version = 1 +requires-python = ">=3.11" + +[[package]] +name = "pywin32" +version = "308" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/eb/e2/02652007469263fe1466e98439831d65d4ca80ea1a2df29abecedf7e47b7/pywin32-308-cp311-cp311-win32.whl", hash = "sha256:5d8c8015b24a7d6855b1550d8e660d8daa09983c80e5daf89a273e5c6fb5095a", size = 5928156 }, + { url = "https://files.pythonhosted.org/packages/48/ef/f4fb45e2196bc7ffe09cad0542d9aff66b0e33f6c0954b43e49c33cad7bd/pywin32-308-cp311-cp311-win_amd64.whl", hash = "sha256:575621b90f0dc2695fec346b2d6302faebd4f0f45c05ea29404cefe35d89442b", size = 6559559 }, + { url = "https://files.pythonhosted.org/packages/79/ef/68bb6aa865c5c9b11a35771329e95917b5559845bd75b65549407f9fc6b4/pywin32-308-cp311-cp311-win_arm64.whl", hash = "sha256:100a5442b7332070983c4cd03f2e906a5648a5104b8a7f50175f7906efd16bb6", size = 7972495 }, + { url = "https://files.pythonhosted.org/packages/00/7c/d00d6bdd96de4344e06c4afbf218bc86b54436a94c01c71a8701f613aa56/pywin32-308-cp312-cp312-win32.whl", hash = "sha256:587f3e19696f4bf96fde9d8a57cec74a57021ad5f204c9e627e15c33ff568897", size = 5939729 }, + { url = "https://files.pythonhosted.org/packages/21/27/0c8811fbc3ca188f93b5354e7c286eb91f80a53afa4e11007ef661afa746/pywin32-308-cp312-cp312-win_amd64.whl", hash = "sha256:00b3e11ef09ede56c6a43c71f2d31857cf7c54b0ab6e78ac659497abd2834f47", size = 6543015 }, + { url = "https://files.pythonhosted.org/packages/9d/0f/d40f8373608caed2255781a3ad9a51d03a594a1248cd632d6a298daca693/pywin32-308-cp312-cp312-win_arm64.whl", hash = "sha256:9b4de86c8d909aed15b7011182c8cab38c8850de36e6afb1f0db22b8959e3091", size = 7976033 }, + { url = "https://files.pythonhosted.org/packages/a9/a4/aa562d8935e3df5e49c161b427a3a2efad2ed4e9cf81c3de636f1fdddfd0/pywin32-308-cp313-cp313-win32.whl", hash = "sha256:1c44539a37a5b7b21d02ab34e6a4d314e0788f1690d65b48e9b0b89f31abbbed", size = 5938579 }, + { url = "https://files.pythonhosted.org/packages/c7/50/b0efb8bb66210da67a53ab95fd7a98826a97ee21f1d22949863e6d588b22/pywin32-308-cp313-cp313-win_amd64.whl", hash = "sha256:fd380990e792eaf6827fcb7e187b2b4b1cede0585e3d0c9e84201ec27b9905e4", size = 6542056 }, + { url = "https://files.pythonhosted.org/packages/26/df/2b63e3e4f2df0224f8aaf6d131f54fe4e8c96400eb9df563e2aae2e1a1f9/pywin32-308-cp313-cp313-win_arm64.whl", hash = "sha256:ef313c46d4c18dfb82a2431e3051ac8f112ccee1a34f29c263c583c568db63cd", size = 7974986 }, +] + +[[package]] +name = "ys" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "pywin32" }, +] + +[package.metadata] +requires-dist = [{ name = "pywin32", specifier = ">=308" }] diff --git a/os/android/backup.sh b/os/android/backup.sh new file mode 100644 index 0000000..019897f --- /dev/null +++ b/os/android/backup.sh @@ -0,0 +1,23 @@ +#!/usr/bin/bash + +release_output=$(cat /etc/os-release) +device_model=$(adb shell getprop ro.build.product) +device_brand=$(adb shell getprop ro.product.brand) +backup_date=$(date +'%Y%m%d-%H%M%S') +backup_dir="$device_brand-$device_model/$backup_date" +mkdir -p $backup_dir +echo "Backing up device to: $backup_dir" +declare -a backup_dirs=("Alarms" "DCIM" "Documents" "Download" "Movies" "Music" "Pictures" "Podcasts" "Recordings" "Ringtones" "SwiftBackup") +for v in "${backup_dirs[@]}" +do + if [[ $release_output == *"MSYS2"* ]] || [ -f /git-bash.exe ] || [ -f /msys2.exe ]; then + # We're on Windows, workaround time :) + echo "adb pull /sdcard/$v $backup_dir/$v" > backup.bat + ./backup.bat + rm backup.bat + else + adb pull /sdcard/$v $backup_dir/$v + fi +done +echo "Copying restore script to backup directory..." +cp restore.sh $backup_dir \ No newline at end of file diff --git a/os/android/restore.sh b/os/android/restore.sh new file mode 100644 index 0000000..90f0ab5 --- /dev/null +++ b/os/android/restore.sh @@ -0,0 +1,15 @@ +#!/usr/bin/bash + +release_output=$(cat /etc/os-release) +declare -a backup_dirs=("Alarms" "DCIM" "Documents" "Download" "Movies" "Music" "Pictures" "Podcasts" "Recordings" "Ringtones" "SwiftBackup") +for v in "${backup_dirs[@]}" +do + if [[ $release_output == *"MSYS2"* ]] || [ -f /git-bash.exe ] || [ -f /msys2.exe ]; then + # We're on Windows + echo "adb push $v /sdcard/" > restore.bat + ./restore.bat + rm restore.bat + else + adb push $v /sdcard/ + fi +done