Skip to content

Instantly share code, notes, and snippets.

@ClassicOldSong
Last active November 24, 2025 01:11
Show Gist options
  • Select an option

  • Save ClassicOldSong/925d5233e9994d8886f68fc7b9981e3b to your computer and use it in GitHub Desktop.

Select an option

Save ClassicOldSong/925d5233e9994d8886f68fc7b9981e3b to your computer and use it in GitHub Desktop.
YouTube TV Installer for SteamDeck with uBlock and SponsorBlock
#!/usr/bin/env bash
set -euo pipefail
# ─── PREREQUISITES ────────────────────────────────────────────────────────────
# 1) Ensure flatpak is available
if ! command -v flatpak >/dev/null 2>&1; then
echo "Error: flatpak is not installed. Please install flatpak and try again."
exit 1
fi
# 2) Ensure Firefox is installed via Flatpak
if ! flatpak info org.mozilla.firefox >/dev/null 2>&1; then
read -rp "Firefox Flatpak not found. Install org.mozilla.firefox from Flathub now? [Y/n]: " REPLY
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "Firefox is required to continue. Aborting."
exit 1
fi
echo "Installing org.mozilla.firefox from Flathub..."
flatpak install -y flathub org.mozilla.firefox
fi
# ─── CONFIG ────────────────────────────────────────────────────────────────────
NAME="YouTube TV"
PROFILE_NAME="youtube_leanback"
PROFILE_DIR="$HOME/.var/app/org.mozilla.firefox/.mozilla/firefox/$PROFILE_NAME"
DESKTOP_FILE_KIOSK="$HOME/.local/share/applications/${PROFILE_NAME}-firefox-kiosk.desktop"
DESKTOP_FILE_NO_KIOSK="$HOME/.local/share/applications/${PROFILE_NAME}-firefox.desktop"
FLATPAK_CMD="flatpak run org.mozilla.firefox"
UA='Mozilla/5.0 (PS4; Leanback Shell) Gecko/20100101 Firefox/65.0 LeanbackShell/01.00.01.75 Sony PS4/ (PS4, , no, CH)'
URL="https://www.youtube.com/tv#/?env_forceFullAnimation=true&env_isLimitedMemory=false&env_disableStartupDialog=true"
# Curl options: retry up to 3×, 5 s delay, fail on HTTP errors,
# 10 s connect timeout, 60 s overall timeout
CURL_OPTS="--retry 3 --retry-delay 5 --fail --connect-timeout 10 --max-time 60"
echo "Installing $NAME webapp..."
# ─── 1) CLEAN UP OLD INSTALL ───────────────────────────────────────────────────
if [ -d "$PROFILE_DIR" ] || [ -f "$DESKTOP_FILE_KIOSK" ] || [ -f "$DESKTOP_FILE_NO_KIOSK" ]; then
read -rp "Old installation detected. Delete it? [y/N]: " REPLY
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Removing old installation..."
rm -rf "$PROFILE_DIR" "$DESKTOP_FILE_KIOSK" "$DESKTOP_FILE_NO_KIOSK"
else
echo "Keeping existing installation and aborting setup."
exit 0
fi
fi
# ─── 2) CREATE NEW PROFILE ─────────────────────────────────────────────────────
read -rp "About to install YouTube TV web app on your Deck. Proceed? [Y/n]: " REPLY
if [[ $REPLY =~ ^[Nn]$ ]]; then
exit 0
fi
echo "Creating new profile \"$PROFILE_NAME\""
mkdir -p "$PROFILE_DIR"
$FLATPAK_CMD --no-remote -CreateProfile "$PROFILE_NAME $PROFILE_DIR" >/dev/null 2>&1
mkdir -p "$PROFILE_DIR/extensions"
echo
# ─── 3) DOWNLOAD EXTENSIONS ────────────────────────────────────────────────────
UBLOCK_XPI_URL="https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi"
echo "Downloading uBlock Origin from $UBLOCK_XPI_URL"
curl $CURL_OPTS -L "$UBLOCK_XPI_URL" \
-o "$PROFILE_DIR/extensions/[email protected]"
echo
SPONSORBLOCKER_XPI_URL="https://addons.mozilla.org/firefox/downloads/latest/sponsorblock/latest.xpi"
echo "Downloading SponsorBlocker from $SPONSORBLOCKER_XPI_URL"
curl $CURL_OPTS -L "$SPONSORBLOCKER_XPI_URL" \
-o "$PROFILE_DIR/extensions/[email protected]"
echo
TAMPERMONKEY_XPI_URL="https://addons.mozilla.org/firefox/downloads/latest/tampermonkey/latest.xpi"
echo "Downloading Tampermonkey from $TAMPERMONKEY_XPI_URL"
curl $CURL_OPTS -L "$TAMPERMONKEY_XPI_URL" \
-o "$PROFILE_DIR/extensions/[email protected]"
# ─── 4) WRITE USER.JS (UA, DRM & EXTENSIONS ENABLED) ───────────────────────────
cat > "$PROFILE_DIR/user.js" <<EOF
user_pref("general.useragent.override", "$UA");
user_pref("media.eme.enabled", true);
user_pref("media.gmp-widevinecdm.enabled", true);
user_pref("media.gmp-widevinecdm.autoupdate", true);
user_pref("extensions.autoDisableScopes", 0);
user_pref("extensions.enabledScopes", 15);
EOF
# ─── 5) WRITE DESKTOP ENTRIES ──────────────────────────────────────────────────
mkdir -p "$(dirname "$DESKTOP_FILE_KIOSK")"
# Kiosk-mode entry
cat > "$DESKTOP_FILE_KIOSK" <<EOF
[Desktop Entry]
Type=Application
Name=$NAME
Exec=$FLATPAK_CMD --no-remote -profile "$PROFILE_DIR" --kiosk "$URL"
Icon=im-youtube
Categories=Network;
StartupNotify=false
EOF
# Non-kiosk entry
cat > "$DESKTOP_FILE_NO_KIOSK" <<EOF
[Desktop Entry]
Type=Application
Name=$NAME (Browser)
Exec=$FLATPAK_CMD --no-remote -profile "$PROFILE_DIR" "$URL"
Icon=im-youtube
Categories=Network;
StartupNotify=false
EOF
echo
echo "✅ Installation complete!"
echo " • Profile: $PROFILE_DIR"
echo " • Kiosk desktop: $DESKTOP_FILE_KIOSK"
echo " • Browser desktop: $DESKTOP_FILE_NO_KIOSK"
echo
echo "To add to Steam, right-click either entry in your Application menu and select “Add to Steam”."
echo
read -rp "Press Enter to launch YouTube TV in browser mode and install HQ Thumbnail plugin, or Ctrl+C to quit..." _
# Launch main YouTube TV URL in background
echo "Launching YouTube TV in browser mode..."
$FLATPAK_CMD --no-remote -profile "$PROFILE_DIR" "$URL" > /dev/null 2>&1 &
# Wait a few seconds for the extensions to install
sleep 3
# Now open the HQ Thumbnail userscript URL
echo "Installing HQ Thumbnail plugin..."
HQ_THUMB_URL="https://gist.githubusercontent.com/ClassicOldSong/ac88b8b0142d329f004527c1833ccd2d/raw/youtube_leanback_hq_thumb.user.js"
$FLATPAK_CMD --no-remote -profile "$PROFILE_DIR" "$HQ_THUMB_URL" > /dev/null 2>&1 &
exit 0
@kopiezzo
Copy link

Hello! Is it possible for you to create a similar app for twitch and kick? I’m not sure how to adapt it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment