diff --git a/apps/Lutris/README.md b/apps/Lutris/README.md index 3eee7ce..c75d567 100644 --- a/apps/Lutris/README.md +++ b/apps/Lutris/README.md @@ -2,7 +2,7 @@ ## `preloader.sh` Execute multiple scripts in a folder (default is `./preloader`), usually useful for Lutris Pre-launch/Post-exit script + Logging is enabled by default, but can be disabled by changing DEBUG to 0 in script source (`DEBUG=0`) -> This script will execute scripts in **current directory** *(where `preloader.sh` is executed)*, so for example if a script need a file called `nightmare`, and preloader.sh is in `~`, **put it in `~`** *instead of `~/preloader/nightmare`* +> This script will execute scripts in **current working directory** *(where `preloader.sh` is executed)*, so for example if a script need a file called `nightmare`, and preloader.sh is in `~`, **put the file in `~`** *instead of `~/preloader/`* ### Installation + To download `preloader.sh` itself: ```sh @@ -11,16 +11,21 @@ chmod +x preloader.sh ``` + After that, copy/move this script to the game prefix you want to use, then in Lutris: - Set pre-launch script in Lutris to where `preloader.sh` is located. - - Disable **Wait for pre-launch script completion** + - Disable **Wait for pre-launch script completion** (optional) + **IMPORTANT**: Now, to add pre-launch script, instead of setting them in Lutris, add them to `./preloader` (or the folder you specified). + Enjoy :L +### Documentation +There are environment variables to control how preloader.sh work: ++ `PRELOADER_PATH=./preloader`: Path to preload scripts. ++ `PRELOADER_DEBUG=0`: Enable debug (1) or disable it (0) + ## `discord_rpc.sh` Launch `winediscordrpcbridge.exe`, to be able to get Discord Rich Presence on Wine applications on the specified prefix. ### Installation -+ To install you must have `winediscordrpcbridge.exe` present, if not you can download latest version by executing ++ To install you must have [`winediscordrpcbridge.exe`](https://github.com/0e4ef622/wine-discord-ipc-bridge/) present, if not you can download latest version by executing ```sh curl -OL https://github.com/0e4ef622/wine-discord-ipc-bridge/releases/latest/download/winediscordipcbridge.exe ``` 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 index dbe5c97..89e3645 --- a/apps/Lutris/preloader.sh +++ b/apps/Lutris/preloader.sh @@ -2,8 +2,10 @@ # Lutris pre-loader script, for allowing loading multiple pre-load scripts. # Enabling debug will enable the script output. -FOLDER="./preloader" -DEBUG=1 + +# Folder path (relative to Lutris prefix directory) +FOLDER="${PRELOADER_PATH:-"./preloader"}" +DEBUG="${PRELOADER_DEBUG:-0}" execute_file () { # Just in case... @@ -11,14 +13,19 @@ execute_file () { if [[ $DEBUG -eq 0 ]]; then nohup "$1" >/dev/null 2>&1 & else - # No this is not as smart as you think... - filename=$(echo "$1" | cut -d "/" -f3) + fullfile="$1" + filename="${fullfile##*/}" nohup "$1" > ./logs/"$FOLDER"_"$filename".log 2>&1 & fi } +if [[ $DEBUG -ne 0 ]]; then + echo "!!!DEBUGGING ENABLED!!!" + echo "Debug log may leak your sensitive information, use with caution." + echo "!!!DEBUGGING ENABLED!!!" + mkdir -p "$FOLDER" ./logs/ +fi echo "Checking directory..." -mkdir -p "$FOLDER" ./logs/ for file in "$FOLDER"/*.*; do [ -e "$file" ] || continue echo "Found $file, loading..." 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/discord/openasar-installer.py b/apps/discord/openasar-installer.py new file mode 100644 index 0000000..231fd30 --- /dev/null +++ b/apps/discord/openasar-installer.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +from pathlib import Path +from urllib import request +from shutil import which + +def find_discord_asar(discord_exec: str) -> Path | None: + dis_loc = which(discord_exec) + if not dis_loc: + return + dis = Path(dis_loc) + with dis.open("r") as f: + try: + content = f.read(256) + except UnicodeDecodeError: + # Official Discord app, the binary is hopefully symlink + # e.g. /usr/bin/discord -> /opt/discord/Discord + asar_path = dis.resolve().parent.joinpath("resources/app.asar") + if asar_path.is_file(): + return asar_path + else: + # Discord wrapper script (Discord system Electron, etc.) + for v in content.split(): + if "app.asar" not in v: + continue + # v is full path to app.asar + # e.g. /usr/lib/discord-canary/app.asar + return Path(v) + + +def download_openasar(): + file, _ = request.urlretrieve("") + return file + +def main(): + print(find_discord_asar("discord-canary")) + # print("Downloading OpenAsar (nightly)...") + # file = request.urlretrieve("") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/apps/lutris/README.md b/apps/lutris/README.md new file mode 100644 index 0000000..c75d567 --- /dev/null +++ b/apps/lutris/README.md @@ -0,0 +1,45 @@ +# Lutris scripts +## `preloader.sh` +Execute multiple scripts in a folder (default is `./preloader`), usually useful for Lutris Pre-launch/Post-exit script ++ Logging is enabled by default, but can be disabled by changing DEBUG to 0 in script source (`DEBUG=0`) +> This script will execute scripts in **current working directory** *(where `preloader.sh` is executed)*, so for example if a script need a file called `nightmare`, and preloader.sh is in `~`, **put the file in `~`** *instead of `~/preloader/`* +### Installation ++ To download `preloader.sh` itself: +```sh +curl -OL https://gitlab.com/tretrauit/scripts/-/raw/main/apps/Lutris/preloader.sh +chmod +x preloader.sh +``` ++ After that, copy/move this script to the game prefix you want to use, then in Lutris: + - Set pre-launch script in Lutris to where `preloader.sh` is located. + - Disable **Wait for pre-launch script completion** (optional) + ++ **IMPORTANT**: Now, to add pre-launch script, instead of setting them in Lutris, add them to `./preloader` (or the folder you specified). ++ Enjoy :L + +### Documentation +There are environment variables to control how preloader.sh work: ++ `PRELOADER_PATH=./preloader`: Path to preload scripts. ++ `PRELOADER_DEBUG=0`: Enable debug (1) or disable it (0) + +## `discord_rpc.sh` +Launch `winediscordrpcbridge.exe`, to be able to get Discord Rich Presence on Wine applications on the specified prefix. + +### Installation ++ To install you must have [`winediscordrpcbridge.exe`](https://github.com/0e4ef622/wine-discord-ipc-bridge/) present, if not you can download latest version by executing +```sh +curl -OL https://github.com/0e4ef622/wine-discord-ipc-bridge/releases/latest/download/winediscordipcbridge.exe +``` +or use my build (latest commit: `master/9d56418`) +```sh +curl -OL https://github.com/teppyboy/releases/releases/download/git%2B0e4ef622%2Fwine-discord-ipc-bridge%2Bmaster%2F9d56418/winediscordipcbridge.exe +``` ++ Then to download `discord_rpc.sh` itself: +```sh +curl -OL https://gitlab.com/tretrauit/scripts/-/raw/main/apps/Lutris/discord_rpc.sh +chmod +x discord_rpc.sh +``` ++ After that, copy/move this script to the game prefix you want to use, then in Lutris: + - Set pre-launch script in Lutris to where `discord_rpc.sh` is located. + - Disable **Wait for pre-launch script completion** + ++ Enjoy :L diff --git a/apps/lutris/discord_rpc.sh b/apps/lutris/discord_rpc.sh new file mode 100644 index 0000000..6968228 --- /dev/null +++ b/apps/lutris/discord_rpc.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Launch winediscordipcbridge.exe automatically. + +echo "wine: $WINE" +echo "prefix: $WINEPREFIX" +$WINE ./winediscordipcbridge.exe diff --git a/apps/lutris/enable-picom-ingame.sh b/apps/lutris/enable-picom-ingame.sh new file mode 100644 index 0000000..878fd02 --- /dev/null +++ b/apps/lutris/enable-picom-ingame.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Put your game process name here (can be full name or short name) +# If it doesn't work for .exe file, try .e instead +# it may work. +PROCESS="" + +echo "Waiting for '$PROCESS' to start..." +until _=$(pidof $PROCESS) +do + sleep 1 +done + +echo "Starting picom..." +picom --experimental-backends & +picom_pid=$! +echo "picom PID: $picom_pid" + +echo "Waiting for '$PROCESS' to exit..." +while [[ $(pidof $PROCESS) ]]; do + sleep .5 +done +echo "Killing picom..." +kill -15 $picom_pid +echo "Done." diff --git a/apps/lutris/preloader.sh b/apps/lutris/preloader.sh new file mode 100644 index 0000000..89e3645 --- /dev/null +++ b/apps/lutris/preloader.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Lutris pre-loader script, for allowing loading multiple pre-load scripts. + +# Enabling debug will enable the script output. + +# Folder path (relative to Lutris prefix directory) +FOLDER="${PRELOADER_PATH:-"./preloader"}" +DEBUG="${PRELOADER_DEBUG:-0}" + +execute_file () { + # Just in case... + chmod +x "$1" + if [[ $DEBUG -eq 0 ]]; then + nohup "$1" >/dev/null 2>&1 & + else + fullfile="$1" + filename="${fullfile##*/}" + nohup "$1" > ./logs/"$FOLDER"_"$filename".log 2>&1 & + fi +} + +if [[ $DEBUG -ne 0 ]]; then + echo "!!!DEBUGGING ENABLED!!!" + echo "Debug log may leak your sensitive information, use with caution." + echo "!!!DEBUGGING ENABLED!!!" + mkdir -p "$FOLDER" ./logs/ +fi +echo "Checking directory..." +for file in "$FOLDER"/*.*; do + [ -e "$file" ] || continue + echo "Found $file, loading..." + execute_file "$file" +done + diff --git a/apps/pinEApple/pinEApple-portable-launcher.sh b/apps/pineapple-yuzu/pinEApple-portable-launcher.sh similarity index 100% rename from apps/pinEApple/pinEApple-portable-launcher.sh rename to apps/pineapple-yuzu/pinEApple-portable-launcher.sh 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 new file mode 100644 index 0000000..ffba42a --- /dev/null +++ b/apps/spotify/wine/install-blockthespot.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +declare -a deps=("curl" "unzip" "rm" "7z" "python3") +declare -a patchfiles=("chrome_elf.dll" "config.ini") + +if (( $EUID == 0 )); then + echo "Do not run this script as root." + exit +fi + +adPatchScript=$(cat << EOF +#!/usr/bin/python3 +import re +from pathlib import Path + +print("Patching xpui.js...") +xpui = Path("./xpui/xpui.js") +xpui_content = xpui.read_text(encoding="utf-8") +replace_ad = re.sub(r"(\.ads\.leaderboard\.isEnabled)(}|\))", r"\1&&false\2", xpui_content) +replace_upgrade = re.sub(r"\.createElement\([^.,{]+,{onClick:[^.,]+,className:[^.]+\.[^.]+\.UpgradeButton}\),[^.(]+\(\)", "", replace_ad) +xpui.write_text(replace_upgrade, encoding="utf-8") +EOF +) + +[[ -z "${WINEPREFIX}" ]] && WINEPREFIX="$HOME/.wine" || WINEPREFIX="${WINEPREFIX}" + +SPOTIFY="$WINEPREFIX/drive_c/users/$(whoami)/AppData/Roaming/Spotify/" +SPOTIFY_APPS="$SPOTIFY/Apps/" +xpuiBundlePath="$SPOTIFY_APPS/xpui.spa" +xpuiUnpackedPath="$SPOTIFY_APPS/xpui/xpui.js" + +echo "BlockTheSpot install script for Spotify (Wine version)" +echo "BlockTheSpot: https://github.com/mrpond/BlockTheSpot/" +echo "Current Wineprefix: $WINEPREFIX" +TMPDIR=$(mktemp -d) +cd $TMPDIR + +for v in "${deps[@]}" +do + if ! [ -x /usr/bin/$v ]; then + echo "Dependency '$v' not found" + exit + fi +done + +if ! [ -d "$SPOTIFY" ]; then + echo "Spotify not found, make sure you're using correct wineprefix..." + exit +fi + +if [ "$1" == "uninstall" ]; then + if [ -f "$SPOTIFY/chrome_elf_bak.dll" ]; then + echo "Uninstalling BlockTheSpot..." + for v in "${patchfiles[@]}" + do + rm "$SPOTIFY/$v" + done + mv "$SPOTIFY/chrome_elf_bak.dll" "$SPOTIFY/chrome_elf.dll" + echo "Uninstalling xpui patch if found..." + mv "$xpuiBundlePath.bak" "$xpuiBundlePath" + fi + echo "Uninstalling BlockTheSpot (IF INSTALLED) completed." + exit +fi + +echo "Downloading BlockTheSpot..." +curl -OL "https://github.com/mrpond/BlockTheSpot/releases/latest/download/chrome_elf.zip" + +echo "Extracting BlockTheSpot..." +unzip -d chrome_elf chrome_elf.zip + +if [ -f "$SPOTIFY/chrome_elf.dll" ] && ! [ -f "$SPOTIFY/chrome_elf_bak.dll" ]; then + echo "Backuping files..." + mv "$SPOTIFY/chrome_elf.dll" "$SPOTIFY/chrome_elf_bak.dll" +fi + +WINEPREFIX=$WINEPREFIX wineserver -k + +echo "Patching Spotify..." +for v in "${patchfiles[@]}" +do + cp "./chrome_elf/$v" "$SPOTIFY/$v" +done + +read -p "Do you want to remove ad placeholder and upgrade button? (y/n) " -n 1 -r +echo # (optional) move to a new line +if [[ $REPLY =~ ^[Yy]$ ]] +then + if [ -f "$xpuiBundlePath" ]; then + echo "Patching xpui.spa..." + if ! [ -f "$xpuiBundlePath.bak" ]; then + mv "$xpuiBundlePath" "$xpuiBundlePath.bak" + fi + unzip -d xpui "$xpuiBundlePath.bak" + fi + echo "$adPatchScript" > "./patch.py" + python3 ./patch.py + 7z a xpui.zip "./xpui/*" + mv xpui.zip $xpuiBundlePath +fi + +echo "Patching completed, open Spotify and enjoy :D" +echo "Temporary directory used $TMPDIR" diff --git a/apps/spotify/wine/soggfy.sh b/apps/spotify/wine/soggfy.sh new file mode 100644 index 0000000..72e017a --- /dev/null +++ b/apps/spotify/wine/soggfy.sh @@ -0,0 +1,60 @@ +#!/usr/bin/bash + +if (( $EUID == 0 )); then + echo "Do not run this script as root." + exit +fi + +[[ -z "${WINEPREFIX}" ]]; WINEPREFIX="$HOME/.wine" +[[ -z "${WINE}" ]]; WINE="wine" + +pfx_arch=$(grep '#arch' "$WINEPREFIX/system.reg" | cut -d "=" -f2) +echo "Wine binary: $WINE" +echo "Detected wineprefix: $WINEPREFIX ($pfx_arch)" + +download_ffmpeg() { + if [[ pfx_arch == "win64" ]]; then + repo_url="https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/latest" + else + repo_url="https://api.github.com/repos/sudo-nautilus/FFmpeg-Builds-Win32/releases/latest" + fi + asset_info=$(curl -s "$repo_url" | jq '.assets | first(.[] | select(.name | match("ffmpeg")))') + asset_name=$(echo $asset_info | jq -r '.name') + echo "Downloading $asset_name..." + curl -OL "$(echo $asset_info | jq -r '.browser_download_url')" + echo "Extracting.." + unzip -j $asset_name "${asset_name%.*}/bin/*" -d "./ffmpeg/" + rm $asset_name +} + +download_soggfy() { + repo_url="https://api.github.com/repos/Rafiuth/Soggfy/releases/latest" + asset_info=$(curl -s "$repo_url" | jq '.assets[0]') + asset_name=$(echo $asset_info | jq -r '.name') + echo "Downloading $asset_name..." + curl -OL "$(echo $asset_info | jq -r '.browser_download_url')" + echo "Extracting.." + unzip -j $asset_name "${asset_name%.*}/*" -d "." + rm $asset_name +} + +if [ ! -f ./Soggfy.js ]; then + echo "Soggfy not found, downloading..." + download_soggfy +fi + +if [ ! -d "./ffmpeg/" ]; then + echo "FFmpeg not found, downloading..." + mkdir ./ffmpeg/ + download_ffmpeg +fi + +echo "Waiting for Spotify to start..." +until _=$(pidof Spotify.exe) +do + sleep 1 +done + +echo "Injecting..." +WINEPREFIX=$WINEPREFIX $WINE Injector.exe +echo "Done." diff --git a/apps/termux/install-termux-x11.bash b/apps/termux/install-termux-x11.bash new file mode 100644 index 0000000..de86155 --- /dev/null +++ b/apps/termux/install-termux-x11.bash @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "Installing dependencies..." +pkg install aria2 termux-x11 +termux-setup-storage +mkdir -p ./tmp/ +echo "Downloading Termux-x11..." +aria2c -d ./tmp/ https://nightly.link/termux/termux-x11/workflows/debug_build/master/termux-x11.zip +unzip ./tmp/termux-x11.zip -d ./tmp/ +rm termux-x11.zip +echo "Installing..." +apt install ./tmp/termux-x11.deb +mv ./tmp/app-debug.apk ~/storage/shared/Downloads/ +echo "NOW PLEASE GO TO YOUR DOWNLOAD FOLDER AND INSTALL TERMUX-X11 MANUALLY." diff --git a/games/aov/.gitkeep b/games/aov/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/games/lol/linux/README.md b/games/lol/linux/README.md index 0e843b8..f27f622 100644 --- a/games/lol/linux/README.md +++ b/games/lol/linux/README.md @@ -20,9 +20,22 @@ chmod +x sulaunchhelper2.sh - Enable **Disable Lutris Runtime** > Failure to do above steps will result in Zenity can't show necessary messages dialog so LoL UI can't launch properly. + Enjoy your LoL experience :P -## `garena_wrapper.sh` + +## [`discord_rpc.sh`](../../../apps/Lutris#discord_rpcsh) ++ This script will bridge Discord RPC from LoL prefix to your linux Discord. +> Note: The script in current directory [`discord_rpc.sh`](./discord_rpc.sh) is modified from the script mentioned above to work properly with `sulaunchhelper2.sh`, +the installation is the same **except** when installing the script itself, execute this instead: +```sh +curl -OL https://gitlab.com/tretrauit/scripts/-/raw/main/games/LoL/linux/discord_rpc.sh +chmod +x discord_rpc.sh +``` +## Deprecated + +### `garena_wrapper.sh` +> Garena no longer owns LoL so to play LoL you need to use Rito Client. + This script automates the launching of [lol.py](https://github.com/nhubaotruong/league-of-legends-linux-garena-script) (LoL in Garena client) so you don't have to manually do it ;) -### Installation +#### Installation > This script no longer wraps `syscall_check.sh`, if you need to execute that script alongside this one, I recommend you to take a look at [`preloader.sh`](../../../apps/Lutris#preloadersh) If you plan to use `preloader.sh` then I **highly recommend you** to **disable logging**, because **lol.py and `preloader.sh` will log your token to ./preloader/preloader_garena_wrapper.sh.log if you keep it enabled**, hence your account may get compromised. @@ -42,13 +55,4 @@ chmod +x garena_wrapper.sh - Disable **Wait for pre-launch script completion** - Enable **Disable Lutris Runtime** > Failure to do above steps will result in Zenity can't show necessary messages dialog so LoL UI may not launch properly (it'll still launch if you use `sulaunchhelper2.sh` and have installed it correctly). -+ Enjoy your Garena LoL experience :P - -## [`discord_rpc.sh`](../../../apps/Lutris#discord_rpcsh) -+ This script will bridge Discord RPC from LoL prefix to your linux Discord. -> Note: The script in current directory [`discord_rpc.sh`](./discord_rpc.sh) is modified from the script mentioned above to work properly with `sulaunchhelper2.sh`, -the installation is the same **except** when installing the script itself, execute this instead: -```sh -curl -OL https://gitlab.com/tretrauit/scripts/-/raw/main/games/LoL/linux/discord_rpc.sh -chmod +x discord_rpc.sh -``` ++ Enjoy your Garena LoL experience :P \ No newline at end of file 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/userscripts/hidemy.name-free-ipport-export.user.js b/userscripts/hidemy.name-free-ipport-export.user.js index e726615..8453cf8 100644 --- a/userscripts/hidemy.name-free-ipport-export.user.js +++ b/userscripts/hidemy.name-free-ipport-export.user.js @@ -9,7 +9,7 @@ // @run-at document-idle // @homepageURL https://gitlab.com/tretrauit/scripts // @supportURL https://gitlab.com/tretrauit/scripts/-/issues -// @downloadURL https://gitlab.com/tretrauit/scripts/-/raw/main/userscripts/hidemy.name-free-ipport-export.user.js.user.js +// @downloadURL https://gitlab.com/tretrauit/scripts/-/raw/main/userscripts/hidemy.name-free-ipport-export.user.js // ==/UserScript== setTimeout(function() { diff --git a/userscripts/messenger-dynamic-sidebar.user.js b/userscripts/messenger-dynamic-sidebar.user.js index 4c21729..72c0654 100644 --- a/userscripts/messenger-dynamic-sidebar.user.js +++ b/userscripts/messenger-dynamic-sidebar.user.js @@ -32,6 +32,9 @@ function findElement(tag, properties) { } function getAncestor(element, level) { + if (element == null) { + return null; + } for (let i = 0; i < level; i++) { element = element.parentNode; } @@ -39,29 +42,42 @@ function getAncestor(element, level) { } console.log("Scanning class for components..."); +// Search box let searchBox = findElement("input", {"aria-autocomplete": "list"}); -if (searchBox != null) { - searchBox = getAncestor(searchBox, 7); +if (searchBox == null) { + console.warn("Failed to get searchBox element."); + throw new Error(); } -let textHeader = findElement("span", {"style": "line-height: 28px;"}); +searchBox = getAncestor(searchBox, 7); +// Header & Text header +let textHeader = findElement("span", {"style": "line-height: var(--base-line-clamp-line-height); --base-line-clamp-line-height:28px;"}); let header; -if (textHeader != null) { - header = getAncestor(textHeader, 7); - textHeader = textHeader.childNodes[0]; +if (textHeader == null) { + console.warn("Failed to get textHeader element."); + throw new Error(); } +header = getAncestor(textHeader, 7); +textHeader = textHeader.childNodes[0]; +// Unread indicator let unreadIndicator = findElement("span", {"data-visualcompletion": "ignore"}); +// Action bar let actionBar = findElement("div", {"aria-expanded": "false"}); -if (actionBar != null) { - actionBar = actionBar.parentNode; +if (actionBar == null) { + console.warn("Failed to get actionBar element."); + throw new Error(); } +actionBar = actionBar.parentNode; +// Chats let chats = findElement("div", {"aria-label": "Chats"}); -if (chats != null) { - chats = chats.parentNode; +if (chats == null) { + console.warn("Failed to get chats element."); + throw new Error(); } - +chats = chats.parentNode; +// Print elements console.log("Search box:", searchBox); console.log("Header:", header); console.log("Text header:", textHeader); console.log("Unread message indicator:", unreadIndicator); console.log("Action bar:", actionBar); -console.log("Chat tab:", chats); \ No newline at end of file +console.log("Chat tab:", chats);