From a18b87fa6199429babcbfebf30f0ee5723a802e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=E1=BA=BF=20H=C6=B0ng?= Date: Mon, 1 Jul 2024 20:36:33 +0700 Subject: [PATCH] feat: support non-rooted device --- apps/lutris/discord_rpc.sh | 0 apps/lutris/enable-picom-ingame.sh | 0 apps/lutris/preloader.sh | 0 apps/proxytext/proxytext-wrapper.sh | 0 apps/spotify/wine/install-blockthespot.sh | 0 apps/spotify/wine/soggfy.sh | 0 apps/ws-scrcpy/README.md | 68 ++++++++++++++--------- apps/ws-scrcpy/ws-scrcpy-launcher.py | 10 ++++ games/lol/linux/discord_rpc.sh | 0 games/lol/linux/garena_wrapper.sh | 0 games/lol/linux/sulaunchhelper2.sh | 0 games/lol/linux/syscall_check.sh | 0 os/linux/automount.py | 0 userscripts/ferdium/vencord.user.js | 31 +++++++++++ 14 files changed, 84 insertions(+), 25 deletions(-) mode change 100755 => 100644 apps/lutris/discord_rpc.sh mode change 100755 => 100644 apps/lutris/enable-picom-ingame.sh mode change 100755 => 100644 apps/lutris/preloader.sh mode change 100755 => 100644 apps/proxytext/proxytext-wrapper.sh mode change 100755 => 100644 apps/spotify/wine/install-blockthespot.sh mode change 100755 => 100644 apps/spotify/wine/soggfy.sh mode change 100755 => 100644 games/lol/linux/discord_rpc.sh mode change 100755 => 100644 games/lol/linux/garena_wrapper.sh mode change 100755 => 100644 games/lol/linux/sulaunchhelper2.sh mode change 100755 => 100644 games/lol/linux/syscall_check.sh mode change 100755 => 100644 os/linux/automount.py create mode 100644 userscripts/ferdium/vencord.user.js diff --git a/apps/lutris/discord_rpc.sh b/apps/lutris/discord_rpc.sh old mode 100755 new mode 100644 diff --git a/apps/lutris/enable-picom-ingame.sh b/apps/lutris/enable-picom-ingame.sh old mode 100755 new mode 100644 diff --git a/apps/lutris/preloader.sh b/apps/lutris/preloader.sh old mode 100755 new mode 100644 diff --git a/apps/proxytext/proxytext-wrapper.sh b/apps/proxytext/proxytext-wrapper.sh old mode 100755 new mode 100644 diff --git a/apps/spotify/wine/install-blockthespot.sh b/apps/spotify/wine/install-blockthespot.sh old mode 100755 new mode 100644 diff --git a/apps/spotify/wine/soggfy.sh b/apps/spotify/wine/soggfy.sh old mode 100755 new mode 100644 diff --git a/apps/ws-scrcpy/README.md b/apps/ws-scrcpy/README.md index bcca111..e48b5ff 100644 --- a/apps/ws-scrcpy/README.md +++ b/apps/ws-scrcpy/README.md @@ -4,43 +4,61 @@ ### Notes -- **YOU NEED TO HAVE WS-SCRCPY INSTALLED, ALONG WITH ROOT ACCESS AND DEPENDENCIES** +- **YOU NEED TO HAVE WS-SCRCPY INSTALLED, ALONG WITH DEPENDENCIES** - ~~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 it **will not** work in most cases. +- 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` > Or execute `pkg install root-repo tsu moreutils build-essential nodejs python3 android-tools git termux-api` -- You also need to downgrade npm to version 6 to fix Termux problem: `npm install -g npm@6` +### Installation -> Please ignore the vulnerability message, if you care about it then please don't use this script. +0. Install ws-scrcpy: -- Download ws-scrcpy-launcher.py: - -```bash -curl -OL https://gitlab.com/tretrauit/scripts/-/raw/main/Apps/ws-scrcpy/ws-scrcpy-launcher.py -chmod +x ws-scrcpy-launcher.py -``` - -> Execute `./ws-scrcpy-launcher.py` to launch ws-scrcpy with scrcpy server for local device. - -- Full script for lazy people (including install ws-scrcpy steps): - -```bash -pkg update -pkg install root-repo moreutils build-essential nodejs python3 android-tools git -pkg install tsu -npm install -g npm@6 -cd ~ +```shell git clone https://github.com/NetrisTV/ws-scrcpy cd ./ws-scrcpy +export GYP_DEFINES="android_ndk_path=''" npm install -cd .. -curl -OL https://gitlab.com/tretrauit/scripts/-/raw/main/Apps/ws-scrcpy/ws-scrcpy-launcher.py +``` + +1. Download ws-scrcpy-launcher.py: + +```shell +curl -OL https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/apps/ws-scrcpy/ws-scrcpy-launcher.py chmod +x ws-scrcpy-launcher.py ``` -- The script will tell you to wait for ws-scrcpy to start, and when it starts it'll show the started message with the ip address and the port to access using browsers +2. Execute `./ws-scrcpy-launcher.py` to launch ws-scrcpy with scrcpy server for local device. -> You need to use `adb pair` to pair termux with your device adb server, then you can launch ws-scrcpy as explained above. +> The script will tell you to wait for ws-scrcpy to start, and when it starts it'll show the started message with the ip address and the port to access using browsers + +#### Android 11 and above (where true wireless debugging is available) + +You need to use `adb pair` to pair termux with your device adb server, then you can launch ws-scrcpy as explained above. + +#### Below Android 11 + +You'll have to use your PC to restart ADB in TCP mode with: + +```shell +adb tcpip 5555 +``` +Then after that you can launch ws-scrcpy as explained above. + +> Full script for lazy people (including install ws-scrcpy steps): +> +> ```shell +> pkg update +> pkg install root-repo moreutils build-essential nodejs 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 +> cd .. +> curl -OL https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/apps/ws-scrcpy/ws-scrcpy-launcher.py +> chmod +x ws-scrcpy-launcher.py +> ``` \ No newline at end of file diff --git a/apps/ws-scrcpy/ws-scrcpy-launcher.py b/apps/ws-scrcpy/ws-scrcpy-launcher.py index 08e9d22..a8e6bed 100644 --- a/apps/ws-scrcpy/ws-scrcpy-launcher.py +++ b/apps/ws-scrcpy/ws-scrcpy-launcher.py @@ -11,6 +11,12 @@ from shutil import which APP_UUID="a6db95c2-27db-4b88-a687-c8107d1bc9d6" +def is_root_available(): + output = subprocess.check_output(['su', '-c', 'echo', '"iamgroot"']).decode("utf-8").strip() + if output == "iamgroot": + return True + return False + def Popen(args: list | str, root=False, shell=False, cwd=Path.cwd()): if root: if shell: @@ -120,6 +126,10 @@ def main(): show_notification("Checking for current adb port...") adb_port = None try: + if not is_root_available(): + print("Root access is not available, assuming the port is 5555") + print("You'll have to start adbd manually as instructed in the README.md") + adb_port = 5555 adb_port = get_port_from_process_name("adbd") except: pass diff --git a/games/lol/linux/discord_rpc.sh b/games/lol/linux/discord_rpc.sh old mode 100755 new mode 100644 diff --git a/games/lol/linux/garena_wrapper.sh b/games/lol/linux/garena_wrapper.sh old mode 100755 new mode 100644 diff --git a/games/lol/linux/sulaunchhelper2.sh b/games/lol/linux/sulaunchhelper2.sh old mode 100755 new mode 100644 diff --git a/games/lol/linux/syscall_check.sh b/games/lol/linux/syscall_check.sh old mode 100755 new mode 100644 diff --git a/os/linux/automount.py b/os/linux/automount.py old mode 100755 new mode 100644 diff --git a/userscripts/ferdium/vencord.user.js b/userscripts/ferdium/vencord.user.js new file mode 100644 index 0000000..a41e3f2 --- /dev/null +++ b/userscripts/ferdium/vencord.user.js @@ -0,0 +1,31 @@ +// Vencord polyfills for loading in Ferdium + +function GM_xmlhttpRequest(details) { + var xhr = new XMLHttpRequest(); + xhr.open(details.method, details.url, true, details.password); + xhr.responseType = details.responseType || 'text'; + xhr.timeout = details.timeout || 0; + if (details.headers) { + for (const [name, value] of Object.entries(details.headers)) { + xhr.setRequestHeader(name, value); + } + } + // Events + xhr.onabort = details.onabort; + xhr.onerror = details.onerror; + xhr.onload = details.onload; + xhr.onloadend = details.onloadend; + xhr.onloadstart = details.onloadstart; + xhr.onprogress = details.onprogress; + xhr.onreadystatechange = details.onreadystatechange; + xhr.ontimeout = details.ontimeout; + // Missing fields: anonymous + xhr.send(details.data); + return { + abort: () => xhr.abort(), + } +} +window.GM_xmlhttpRequest = GM_xmlhttpRequest; +window.unsafeWindow = window; +document.head.innerHTML += ``; +eval(await (await fetch("https://raw.githubusercontent.com/Vencord/builds/main/Vencord.user.js")).text());