2021-12-21 13:43:15 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-12-22 09:49:39 +00:00
|
|
|
declare -a deps=("curl" "unzip" "rm" "7z" "python3")
|
2021-12-21 13:43:15 +00:00
|
|
|
declare -a patchfiles=("chrome_elf.dll" "config.ini")
|
|
|
|
|
|
|
|
if (( $EUID == 0 )); then
|
|
|
|
echo "Do not run this script as root."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2021-12-22 09:49:39 +00:00
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2021-12-21 13:43:15 +00:00
|
|
|
[[ -z "${WINEPREFIX}" ]] && WINEPREFIX="$HOME/.wine" || WINEPREFIX="${WINEPREFIX}"
|
|
|
|
|
2021-12-22 09:49:39 +00:00
|
|
|
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)"
|
2021-12-21 13:43:15 +00:00
|
|
|
echo "BlockTheSpot: https://github.com/mrpond/BlockTheSpot/"
|
|
|
|
echo "Current Wineprefix: $WINEPREFIX"
|
2021-12-22 09:49:39 +00:00
|
|
|
TMPDIR=$(mktemp -d)
|
2021-12-21 13:43:15 +00:00
|
|
|
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
|
|
|
|
|
2021-12-21 14:17:13 +00:00
|
|
|
if [ "$1" == "uninstall" ]; then
|
2021-12-21 14:20:50 +00:00
|
|
|
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"
|
2021-12-22 09:49:39 +00:00
|
|
|
echo "Uninstalling xpui patch if found..."
|
|
|
|
mv "$xpuiBundlePath.bak" "$xpuiBundlePath"
|
2021-12-21 14:20:50 +00:00
|
|
|
fi
|
2021-12-22 09:49:39 +00:00
|
|
|
echo "Uninstalling BlockTheSpot (IF INSTALLED) completed."
|
2021-12-21 14:17:13 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2021-12-21 13:43:15 +00:00
|
|
|
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
|
|
|
|
|
2021-12-22 09:49:39 +00:00
|
|
|
if [ -f "$SPOTIFY/chrome_elf.dll" ] && ! [ -f "$SPOTIFY/chrome_elf_bak.dll" ]; then
|
2021-12-21 13:53:52 +00:00
|
|
|
echo "Backuping files..."
|
|
|
|
mv "$SPOTIFY/chrome_elf.dll" "$SPOTIFY/chrome_elf_bak.dll"
|
2021-12-21 13:43:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
WINEPREFIX=$WINEPREFIX wineserver -k
|
|
|
|
|
|
|
|
echo "Patching Spotify..."
|
|
|
|
for v in "${patchfiles[@]}"
|
|
|
|
do
|
|
|
|
cp "./chrome_elf/$v" "$SPOTIFY/$v"
|
|
|
|
done
|
|
|
|
|
2021-12-22 09:49:39 +00:00
|
|
|
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"
|