#!/usr/bin/env bash BLOCKTHESPOT_VERSION="1.2.32.985.g3be2709c" # dependencies check command -v perl >/dev/null || { echo -e "\nperl was not found, exiting...\n" >&2; exit 1; } command -v unzip >/dev/null || { echo -e "\nunzip was not found, exiting...\n" >&2; exit 1; } command -v zip >/dev/null || { echo -e "\nzip was not found, exiting...\n" >&2; exit 1; } # Script flags APP_PATH="/Applications/Spotify.app" FORCE_FLAG='false' HIDE_PODCASTS_FLAG='false' PATH_FLAG='false' UPDATE_FLAG='false' CUSTOM_APP_PATH='false' SKIP_CODE_SIGNATURE='false' DEVELOPER_MODE='false' UNINSTALL_FLAG='false' while getopts 'UfhSPud:' flag; do case "${flag}" in U) UNINSTALL_FLAG='true' ;; f) FORCE_FLAG='true' ;; h) HIDE_PODCASTS_FLAG='true' ;; S) SKIP_CODE_SIGNATURE='true' ;; d) DEVELOPER_MODE='true' ;; P) APP_PATH="${OPTARG}" PATH_FLAG='true' ;; u) UPDATE_FLAG='true' ;; *) echo "Error: Flag not supported." exit ;; esac done # Inital paths and filenames if [[ "${PATH_FLAG}" == 'false' ]]; then if [[ -d "${HOME}${APP_PATH}" ]]; then INSTALL_PATH="${HOME}${APP_PATH}" elif [[ -d "${APP_PATH}" ]]; then INSTALL_PATH="${APP_PATH}" else echo -e "\nSpotify not found. Exiting...\n" exit fi else if [[ -d "${APP_PATH}" ]]; then INSTALL_PATH="${APP_PATH}" else echo -e "\nSpotify not found. Exiting...\n" exit fi fi XPUI_PATH="${INSTALL_PATH}/Contents/Resources/Apps" APP_BINARY="${INSTALL_PATH}/Contents/MacOS/Spotify" APP_BINARY_BAK="${INSTALL_PATH}/Contents/MacOS/Spotify.bak" XPUI_DIR="${XPUI_PATH}/xpui" XPUI_BAK="${XPUI_PATH}/xpui.bak" XPUI_SPA="${XPUI_PATH}/xpui.spa" XPUI_JS="${XPUI_DIR}/xpui.js" XPUI_CSS="${XPUI_DIR}/xpui.css" VENDOR_XPUI_JS="${XPUI_DIR}/vendor~xpui.js" XPUI_DESKTOP_MODAL_JS="${XPUI_DIR}/xpui-desktop-modals.js" if [[ "${UNINSTALL_FLAG}" == "true" ]]; then if [[ ! -f "${XPUI_BAK}" ]] || [[ ! -f "${APP_BINARY_BAK}" ]]; then echo -e "Backup not found, BlockTheSpot-Mac has not been used on this installation." exit fi echo "Backup found, restoring original..." rm "${XPUI_SPA}" rm "${APP_BINARY}" mv "${XPUI_BAK}" "${XPUI_SPA}" mv "${APP_BINARY_BAK}" "${APP_BINARY}" echo -e "BlockTheSpot-Mac has been uninstalled!" exit fi # Find client version CLIENT_VERSION=$(awk '/CFBundleShortVersionString/{getline; print}' "${INSTALL_PATH}/Contents/Info.plist" | cut -d\> -f2- | rev | cut -d. -f2- | rev) # Get Mac OS Architecture MAC_ARCH=$(uname -m) # Version function for version comparison function ver { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } # Perl command PERL="perl -pi -w -e" # Ad-related regex AD_EMPTY_AD_BLOCK='s|adsEnabled:!0|adsEnabled:!1|' AD_PLAYLIST_SPONSORS='s|allSponsorships||' AD_SPONSORS='s/ht.{14}\...\..{7}\....\/.{8}ap4p\/|ht.{14}\...\..{7}\....\/s.{15}t\/v.\///g' # AD_UPGRADE_BUTTON='s/(return|.=.=>)"free"===(.+?)(return|.=.=>)"premium"===/$1"premium"===$2$3"free"===/g' # AD_AUDIO_ADS='s/(case .:|async enable\(.\)\{)(this.enabled=.+?\(.{1,3},"audio"\),|return this.enabled=...+?\(.{1,3},"audio"\))((;case 4:)?this.subscription=this.audioApi).+?this.onAdMessage\)/$1$3.cosmosConnector.increaseStreamTime(-100000000000)/' AD_BILLBOARD='s|.(?=\?\[.{1,6}[a-zA-Z].leaderboard,)|false|' AD_UPSELL='s|Enables quicksilver in-app messaging modal",default:\K!.(?=})|false|s' AD_ADS='s#/a\Kd(?=s/v1)|/a\Kd(?=s/v2/t)|/a\Kd(?=s/v2/se)#b#gs' AD_SERV='s|(this\._product_state(?:_service)?=(.))|$1,$2.putOverridesValues({pairs:{ads:'\''0'\'',catalogue:'\''premium'\'',product:'\''premium'\'',type:'\''premium'\''}})|' AD_PATCH_1='s|\x00\K\x61(?=\x64\x2D\x6C\x6F\x67\x69\x63\x2F\x73)|\x00|' AD_PATCH_2='s|\x00\K\x73(?=\x6C\x6F\x74\x73\x00)|\x00|' AD_PATCH_3='s|\x70\x6F\x64\x63\x61\x73\x74\K\x2D\x70|\x20\x70|g' AD_PATCH_4='s|\x70\x6F\x64\x63\x61\x73\x74\K\x2D\x6D\x69|\x20\x6D\x69|g' AD_PATCH_5='s|\x00\K\x67(?=\x61\x62\x6F\x2D\x72\x65\x63\x65\x69\x76\x65\x72\x2D\x73\x65\x72\x76\x69\x63\x65)|\x00|g' HPTO_ENABLED='s|hptoEnabled:!\K0|1|s' HPTO_PATCH='s|(ADS_PREMIUM,isPremium:)\w(.*?ADS_HPTO_HIDDEN,isHptoHidden:)\w|$1true$2true|' # Hide Premium-only features HIDE_DL_QUALITY='s|return \K([^;]+?)(?=\?null[^}]+?desktop\.settings\.downloadQuality\.title)|true|' HIDE_DL_ICON=' .BKsbV2Xl786X9a09XROH {display:none}' HIDE_DL_MENU=' button.wC9sIed7pfp47wZbmU6m.pzkhLqffqF_4hucrVVQA {display:none}' HIDE_VERY_HIGH=' #desktop\.settings\.streamingQuality>option:nth-child(5) {display:none}' # Hide Podcasts/Episodes/Audiobooks on home screen HIDE_PODCASTS3='s/(!Array.isArray\(.\)\|\|.===..length)/$1||e[0].key.includes('\''episode'\'')||e[0].key.includes('\''show'\'')/' MODAL_CREDITS='s;((..createElement|children:\(.{1,7}\))\(.{1,7},\{source:).{1,7}get\("about.copyright",.\),paragraphClassName:.(?=\}\));$1"

About BlockTheSpot-Mac


Nuzair46/BlockTheSpot-Mac
BlockTheSpot Discord
For Windows 10/11

BlockTheSpot-Mac is provided "\;as is"\ without any warranties at the users descretion. Use at your own risk. BlockTheSpot/BlockTheSpot-Mac team is not responsible for any consequences of using this project, More info.

Spotify®\; is a registered trademark of Spotify Group.";' # Log-related regex LOG_1='s|sp://logging/v3/\w+||g' LOG_SENTRY='s|this\.getStackTop\(\)\.client=e|return;$&|' # Updates UPDATE_PATCH='s|\x64(?=\x65\x73\x6B\x74\x6F\x70\x2D\x75\x70)|\x00|g' # Developer mode if [[ "${MAC_ARCH}" == "arm64" ]]; then DEVELOPER_MODE_PATCH='s|\xF8\xFF[\x37\x77\xF7][\x06\x07\x08]\x39\xFF.[\x00\x04]\xB9\xE1[\x03\x43\xC3][\x06\x07\x08]\x91\xE2.[\x02\x03\x13]\x91\K..\x00\x94(?=[\xF7\xF8]\x03)|\x60\x00\x80\xD2|' else DEVELOPER_MODE_PATCH='s|\xFF\xFF\x48\xB8\x65\x76\x65.{5}\x48.{36,40}\K\xE8.{2}(?=\x00\x00)|\xB8\x03\x00|' fi # Credits echo echo "************************" echo "BlockTheSpot-Mac by @Nuzair46" echo "************************" echo # Report versions echo -e "Spotify version: ${CLIENT_VERSION}" echo -e "BlockTheSpot-Mac version: ${BLOCKTHESPOT_VERSION}\n" if [[ $(ver "${CLIENT_VERSION}") -lt $(ver "${BLOCKTHESPOT_VERSION}") ]]; then echo "This version of BlockTheSpot-Mac is not compatible with your Spotify version." echo "Please use an older version of BlockTheSpot-Mac or update Spotify." exit; fi if [[ "${SKIP_CODE_SIGNATURE}" == "true" ]]; then echo "Skipping code signature check..." elif ! command -v codesign &> /dev/null; then echo "codesign was not found." echo "Install the Xcode command line tools to enable code signature checks." echo "With xcode-select --install"; echo "You can try to skip code signature checks with the -S flag. Exiting..." exit; fi # xpui detection if [[ ! -f "${XPUI_SPA}" ]]; then echo -e "\nxpui not found!\nReinstall Spotify then try again.\nExiting...\n" exit else if [[ "${FORCE_FLAG}" == "false" ]]; then if [[ -f "${XPUI_BAK}" ]] || [[ -f "${APP_BINARY_BAK}" ]]; then echo "BlockTheSpot backup found, BlockTheSpot has already been used on this install." echo -e "Re-run BlockTheSpot using the '-f' flag to force xpui patching.\n" echo "Skipping xpui patches and continuing BlockTheSpot..." XPUI_SKIP="true" else echo "Creating backup..." cp "${XPUI_SPA}" "${XPUI_BAK}" cp "${APP_BINARY}" "${APP_BINARY_BAK}" XPUI_SKIP="false"; fi else if [[ -f "${XPUI_BAK}" ]] || [[ -f "${APP_BINARY_BAK}" ]]; then echo "Backup found, restoring original..." rm "${XPUI_SPA}" rm "${APP_BINARY}" cp "${XPUI_BAK}" "${XPUI_SPA}" cp "${APP_BINARY_BAK}" "${APP_BINARY}" XPUI_SKIP="false" else echo "Creating backup..." cp "${XPUI_SPA}" "${XPUI_BAK}" cp "${APP_BINARY}" "${APP_BINARY_BAK}" XPUI_SKIP="false"; fi; fi; fi # Extract xpui.spa if [[ "${XPUI_SKIP}" == "false" ]]; then echo "Extracting xpui..." unzip -qq "${XPUI_SPA}" -d "${XPUI_DIR}" if grep -Fq "BlockTheSpot" "${XPUI_JS}"; then echo -e "\nWarning: Detected BlockTheSpot patches but no backup file!" echo -e "Further xpui patching not allowed until Spotify is reinstalled/upgraded.\n" echo "Skipping xpui patches and continuing BlockTheSpot..." XPUI_SKIP="true" rm "${XPUI_BAK}" 2>/dev/null rm -rf "${XPUI_DIR}" 2>/dev/null else rm "${XPUI_SPA}"; fi; fi echo "Applying BlockTheSpot patches..." if [[ "${XPUI_SKIP}" == "false" ]]; then echo "Removing ad-related content..." $PERL "${AD_ADS}" "${XPUI_JS}" $PERL "${AD_BILLBOARD}" "${XPUI_JS}" $PERL "${AD_EMPTY_AD_BLOCK}" "${XPUI_JS}" $PERL "${AD_SERV}" "${XPUI_JS}" $PERL "${AD_PLAYLIST_SPONSORS}" "${XPUI_JS}" $PERL "${AD_UPSELL}" "${XPUI_JS}" $PERL "${AD_SPONSORS}" "${XPUI_JS}" $PERL "${HPTO_ENABLED}" "${XPUI_JS}" $PERL "${HPTO_PATCH}" "${XPUI_JS}" echo "Patching Binary..." $PERL "${AD_ADS}" "${APP_BINARY}" $PERL "${AD_PATCH_1}" "${APP_BINARY}" $PERL "${AD_PATCH_2}" "${APP_BINARY}" $PERL "${AD_PATCH_3}" "${APP_BINARY}" $PERL "${AD_PATCH_4}" "${APP_BINARY}" $PERL "${AD_PATCH_5}" "${APP_BINARY}" # Remove Premium-only features echo "Removing premium-only features..." $PERL "${HIDE_DL_QUALITY}" "${XPUI_JS}" echo "${HIDE_DL_ICON}" >> "${XPUI_CSS}" echo "${HIDE_DL_MENU}" >> "${XPUI_CSS}" echo "${HIDE_VERY_HIGH}" >> "${XPUI_CSS}"; fi if [[ "${DEVELOPER_MODE}" == "true" ]]; then echo "Enabling developer mode..." $PERL "${DEVELOPER_MODE_PATCH}" "${APP_BINARY}"; fi # Remove logging if [[ "${XPUI_SKIP}" == "false" ]]; then echo "Removing logging..." $PERL "${LOG_1}" "${XPUI_JS}" $PERL "${LOG_SENTRY}" "${VENDOR_XPUI_JS}"; fi # Modal credits if [[ "${XPUI_SKIP}" == "false" ]]; then echo "Adding credits..." $PERL "${MODAL_CREDITS}" "${XPUI_DESKTOP_MODAL_JS}"; fi # Hide podcasts, episodes and audiobooks on home screen if [[ "${XPUI_SKIP}" == "false" ]]; then if [[ "${HIDE_PODCASTS_FLAG}" == "true" ]]; then if [[ $(ver "${CLIENT_VERSION}") -ge $(ver "1.1.98.683") ]]; then echo "Hiding non-music items on home screen..." $PERL "${HIDE_PODCASTS3}" "${XPUI_JS}"; fi; fi; fi # Automatic updates handling if [[ "${UPDATE_FLAG}" == "true" ]]; then echo "Blocking updates..." $PERL "${UPDATE_PATCH}" "${APP_BINARY}"; fi # Zip files inside xpui folder if [[ "${XPUI_SKIP}" == "false" ]]; then (cd "${XPUI_DIR}"; zip -qq -r ../xpui.spa .) rm -rf "${XPUI_DIR}"; fi # Sign APP_BINARY echo "Signing Spotify..." codesign -f --deep -s - "${APP_PATH}" 2>/dev/null; echo -e "BlockTheSpot finished patching!\n"