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"