Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

chore: the mod is a UI tweak only, the ad, Premium and upsell switches are gone

Vojtěch Škopek5705ca102b62
diff --git a/AGENTS.md b/AGENTS.md
index 206962bd..560e62e1 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -15,7 +15,7 @@ A Theos tweak (Objective-C + Logos) injected into the decrypted Spotify iOS app.
playlist, album and artist pages the way the Music app lays them out with one pinned ⋯ over each, black
throughout, and its own accent colour. No native tweak runs.
-Anything that doesn't draw on Spotify's screens works the same under both: ads, privacy, lyrics
+Anything that doesn't draw on Spotify's screens works the same under both: privacy, lyrics
sources, gestures, blocked artists, flags, Vibrations, Speed and pitch, and the Live Activity. Those
last three were the redesign's until they moved to `Shared/`, so their keys lost the `.redesign.` and
`Core/SGPrefs.h`'s `SGMigrateKey` carries the old ones over at launch.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f6ae1abd..798312be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,7 +12,7 @@
### Fixes
-* Recents with Block telemetry on, Spoof Premium with a 304, lyrics cache eviction, protobuf length overflow, Set rule types, Live Activity update order ([4b21bed](https://github.com/skopevoj/spoti.pw/commit/4b21bed034953c9786521101da9f96197f949b90))
+* Recents with Block telemetry on, lyrics cache eviction, protobuf length overflow, Set rule types, Live Activity update order ([4b21bed](https://github.com/skopevoj/spoti.pw/commit/4b21bed034953c9786521101da9f96197f949b90))
* trim the Lyrics settings page ([76b8577](https://github.com/skopevoj/spoti.pw/commit/76b85776d1b6c4306ade9f2c84cd8039cbae4b55))
* trim the Mod Settings descriptions ([79572ae](https://github.com/skopevoj/spoti.pw/commit/79572ae06b2a606f69d8314d87d57d302e1d0999))
@@ -102,7 +102,6 @@
* add LRCLIB as the floor under the other lyrics sources ([ab78945](https://github.com/skopevoj/spoti.pw/commit/ab78945ecc114e3057af446c9d233d3e8f54cd1b))
* add new record trees flag ([8bbdb6e](https://github.com/skopevoj/spoti.pw/commit/8bbdb6e4eb224df8a7835586848df642068450db))
* Apple Music style lyrics only in the redesign and always on there, the native karaoke copy gone, and AGENTS.md and CLAUDE.md for agents ([cc24a25](https://github.com/skopevoj/spoti.pw/commit/cc24a25e29eaee1b103ca4019747884d3b3793b3))
-* block the ad card under the player and make crossfade and automix play ([55c3c60](https://github.com/skopevoj/spoti.pw/commit/55c3c60f7726e10e1e3bd3e5d0984b56c003e56a))
* declutter the album page and put its blurred cover behind the header ([f414321](https://github.com/skopevoj/spoti.pw/commit/f414321444edb8e8261429677c42560f420c93fd))
* declutter the artist page and fade its photo into a blur ([d169287](https://github.com/skopevoj/spoti.pw/commit/d1692876dcd2f7290cff6da4e5d4f46cb2560f10))
* Home's shortcut tiles hold their cover inset on a surface tinted faintly by it, instead of the stretched blur ([3de8ea1](https://github.com/skopevoj/spoti.pw/commit/3de8ea1431ebca3243c72a282108c829dfadcb71))
diff --git a/README.md b/README.md
index b5005fb8..22cdd8b8 100644
--- a/README.md
+++ b/README.md
@@ -107,7 +107,7 @@ to use, a coffee is a good way to say so.
[cyan](https://github.com/asdfzxcvbn/pyzule-rw) injects, [Theos](https://theos.dev) builds, and
[FLEX](https://github.com/FLEXTool/FLEX), as hopeless's AutoFLEX build in `vendor/`, is the inspector
-the view trees are read through. The ad blocking and the Premium state are ported from
-[EeveeSpotify Reincarnated](https://github.com/SideloadLabs/EeveeSpotifyReincarnated).
+the view trees are read through. The lyrics hook follows
+[EeveeSpotify Reincarnated](https://github.com/SideloadLabs/EeveeSpotifyReincarnated)'s.
GPL-3.0. Not affiliated with Spotify.
diff --git a/docs/tweaks.md b/docs/tweaks.md
index 45f97167..38922cd8 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -71,11 +71,7 @@ A feature is a directory in its layer holding everything about one area of the a
Shared:
- AdBlock/ EeveeSpotify's ad blocking: the ad and upsell services silenced (AdServices.x), ad components out of the
- Hub JSON (AdHubs.x) and the feeds (Feeds.m), Premium pop-ups dropped (AdPopups.x), and the responses
- rewritten on the way in (AdNetwork.x, Premium.m over the protobuf walker in Protobuf.m), with crossfade
- and automix switched on in the player core and crossfade's switch kept in step with its slider (Crossfade.x)
- Privacy/ telemetry blocking and its counters
+ Privacy/ telemetry blocking and its counters, and the Search switches that force their flags off (Clutter.m)
ArtistBlock/ tracks by blocked artists skipped as they start (ArtistSkip.x), the list and the Blocked artists page under Player
Flags/ Spotify's remote-config flags: the provider hook, the generated table, the All flags page and the Labs page
Gestures/ the double tap zones on the player: the grid, what each cell does, the recognizer (each look hooks it on)
@@ -268,11 +264,9 @@ opening out into its sliders, choices, curve or file library while its switch is
changes; the row reads out Off, On or how many effects are on. Home & Library, in the native look only:
the Gradient page (the wash behind the top of Home in one of eight colours, at three strengths and
four heights) and the Home flags, the parts of Home to hide including the DJ button and badge, the
-playlist header, buttons and pills to hide, and the Library flags. Then Premium, ads & privacy
-(EeveeSpotify's Hide ads and Hide upsells, hiding the video carousel and social proof in Search, and
-an Ad and upsell flags page under them, every switch there forcing a flag Spotify ships on to off;
-Spoof Premium; Block telemetry; then what the ad
-blocking and the telemetry blocking have stopped) and Labs (features Spotify built and did not ship,
+playlist header, buttons and pills to hide, and the Library flags. Then Privacy & clutter
+(Block telemetry; hiding the video carousel and social proof in Search, and a Tips page under them,
+every switch there forcing a flag Spotify ships on to off; then what the telemetry blocking has stopped) and Labs (features Spotify built and did not ship,
AI Chat (Martini) first). Last, All flags, Spotify's remote-config flags with a search field and an
Auto / Off / On control per flag (a text field for the number and text ones), and Mod: Updates
(the row reads out where the build stands and opens the changelog of everything newer than it, read
diff --git a/harness/lyrics/build.sh b/harness/lyrics/build.sh
index 9a513cae..ee577d7e 100755
--- a/harness/lyrics/build.sh
+++ b/harness/lyrics/build.sh
@@ -19,7 +19,7 @@ SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)
xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-arc -g ${OPT:--O0} \
-I"$SRC" -I"$SRC/Redesigned/Lyrics" -isysroot "$SDK" -Wall -Wno-deprecated-declarations \
"$HERE/main.m" "$HERE/stubs.m" \
- "$SRC"/Redesigned/Lyrics/SGRKaraokeView.m $( [ -f "$SRC"/Redesigned/Lyrics/LyricsText.m ] && echo "$SRC"/Redesigned/Lyrics/LyricsText.m ) "$SRC"/Shared/Lyrics/KaraokeTiming.m "$SRC"/Shared/AdBlock/Protobuf.m \
+ "$SRC"/Redesigned/Lyrics/SGRKaraokeView.m $( [ -f "$SRC"/Redesigned/Lyrics/LyricsText.m ] && echo "$SRC"/Redesigned/Lyrics/LyricsText.m ) "$SRC"/Shared/Lyrics/KaraokeTiming.m "$SRC"/Shared/Lyrics/Protobuf.m \
"$SRC"/Shared/LyricsSources/SGTTML.m "$SRC"/Redesigned/Kit/SGRTokens.m \
"$SRC"/Core/SGLog.m "$SRC"/Core/SGPrefs.m "$SRC"/Core/SGGlass.m \
-framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreText -framework Foundation \
diff --git a/harness/player/build.sh b/harness/player/build.sh
index 2cb61b9e..8a1becb5 100755
--- a/harness/player/build.sh
+++ b/harness/player/build.sh
@@ -22,7 +22,7 @@ xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-ar
"$SRC"/Redesigned/Kit/SGRTokens.m "$SRC"/Redesigned/Kit/SGRPalette.m "$SRC"/Redesigned/Kit/SGRField.m "$SRC"/Redesigned/Kit/SGRFlow.m \
"$SRC"/Redesigned/Kit/SGRGlass.m "$SRC"/Redesigned/Kit/SGRGlyph.m "$SRC"/Redesigned/Kit/SGRRestyle.m \
"$SRC"/Redesigned/Kit/SGRedesign.m \
- "$SRC"/Redesigned/Lyrics/SGRKaraokeView.m "$SRC"/Redesigned/Lyrics/LyricsText.m "$SRC"/Shared/Lyrics/KaraokeTiming.m "$SRC"/Shared/AdBlock/Protobuf.m \
+ "$SRC"/Redesigned/Lyrics/SGRKaraokeView.m "$SRC"/Redesigned/Lyrics/LyricsText.m "$SRC"/Shared/Lyrics/KaraokeTiming.m "$SRC"/Shared/Lyrics/Protobuf.m \
-framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols \
-o "$OUT/PlayerHarness.app/PlayerHarness"
diff --git a/tweak/Sources/App/About/Usage.m b/tweak/Sources/App/About/Usage.m
index b25862ea..0d0ab9d0 100644
--- a/tweak/Sources/App/About/Usage.m
+++ b/tweak/Sources/App/About/Usage.m
@@ -6,7 +6,6 @@
#import "About.h"
#import "Native/Appearance/Appearance.h"
#import "Native/Player/NowPlaying.h"
-#import "Shared/AdBlock/AdBlock.h"
#import "Shared/ArtistBlock/ArtistBlock.h"
#import "Shared/Gestures/Gestures.h"
#import "Shared/Haptics/Haptics.h"
@@ -94,8 +93,6 @@ NSData *SGUsageBody(void) {
@"artistBlock": @(SGFlag(SGKeyArtistBlock, NO)),
@"gestures": @(SGFlag(SGKeyGestures, NO)),
@"blockTelemetry": @(SGEnabled(SGKeyBlockTelemetry)),
- @"hideAds": @(SGHidden(SGKeyHideAds)),
- @"fakePremium": @(SGHidden(SGKeyFakePremium)),
@"lyricsCard": @(SGFlag(SGKeyLyricsCard, NO)),
@"amoled": @(SGFlag(SGKeyAmoled, NO)),
};
diff --git a/tweak/Sources/App/ModSettings.x b/tweak/Sources/App/ModSettings.x
index 46cc5574..1df0611f 100644
--- a/tweak/Sources/App/ModSettings.x
+++ b/tweak/Sources/App/ModSettings.x
@@ -1,7 +1,7 @@
// Settings: a Mod Settings row at the end of Spotify's settings list opens the mod's own page: the
// Appearance card with Redesigned UI, then a page per part of Spotify, each holding what that part
// offers in the stored look (App/Pages.m: Navbar, Player, and Home & Library for the native look), Audio
-// effects (JamesDSP, Shared/JamesDSP, in either look and applying straight away), Premium, ads & privacy
+// effects (JamesDSP, Shared/JamesDSP, in either look and applying straight away), Privacy & clutter
// and Labs, All flags, a searchable list of every flag with an override per flag, and Mod, the
// build, its updates and links. The same row leads the side drawer's list (trees/test6.txt), above
// Your plan, so the page is a tap from Home, and holding Home on the tab bar opens it too. The tweaks read the switches when they run, so a change
@@ -17,7 +17,7 @@
#import "Settings/SGPageStyle.h"
#import "Settings/SGModPage.h"
#import "Native/Home/Home.h"
-#import "Shared/AdBlock/AdBlock.h"
+#import "Shared/Privacy/Privacy.h"
#import "Shared/Flags/Flags.h"
#import "Shared/JamesDSP/JamesDSPPage.h"
#import "Shared/LiveActivity/LiveActivity.h"
@@ -63,7 +63,7 @@ static UIViewController *modSettingsPage(void) {
SGAppearanceSection(),
SGSection(nil, parts),
SGSection(nil, @[
- pageRow(@"Premium, ads & privacy", @"crown", ^UIViewController *{ return SGAdsSettingsPage(); }),
+ pageRow(@"Privacy & clutter", @"hand.raised", ^UIViewController *{ return SGPrivacySettingsPage(); }),
pageRow(@"Labs", @"testtube.2", ^UIViewController *{ return SGLabsPage(); }),
]),
SGSection(nil, @[
diff --git a/tweak/Sources/Core/SGFlagForce.h b/tweak/Sources/Core/SGFlagForce.h
index 3780048c..86d95a1e 100644
--- a/tweak/Sources/Core/SGFlagForce.h
+++ b/tweak/Sources/Core/SGFlagForce.h
@@ -1,6 +1,6 @@
// The flags something of the mod's forces, gathered in one place so that the flag provider
// (Shared/Flags/Flags.x) and the flag rows of the settings pages (Settings/SGModPage.m) ask here
-// rather than knowing every feature that forces one: the ad blocking, the lyrics sources, the redesign.
+// rather than knowing every feature that forces one: the Search switches, the lyrics sources, the redesign.
//
// A forcer answers a flag key with the value it forces, or nil. `atLaunch` answers for the running
// app, from the switches as they were at launch; `locked`, which may be nil, answers for a settings
diff --git a/tweak/Sources/Settings/SGModPage.m b/tweak/Sources/Settings/SGModPage.m
index 59b3d4b3..a77eec0a 100644
--- a/tweak/Sources/Settings/SGModPage.m
+++ b/tweak/Sources/Settings/SGModPage.m
@@ -257,7 +257,7 @@ static BOOL flagRowOn(SGModRow *row) {
return value && [value boolValue] != row.forceOff;
}
-// A flag something of the mod's forces (Core/SGFlagForce.h: the redesign, the ad blocking): its row
+// A flag something of the mod's forces (Core/SGFlagForce.h: the redesign, the Search switches): its row
// shows what is forced and takes no touch, so the flag has one place to change.
static BOOL flagRowLocked(SGModRow *row) {
return row.flag && SGLockedFlagValue(row.key, NULL) != nil;
diff --git a/tweak/Sources/Shared/AdBlock/AdBlock.h b/tweak/Sources/Shared/AdBlock/AdBlock.h
deleted file mode 100644
index 5fa37cef..00000000
--- a/tweak/Sources/Shared/AdBlock/AdBlock.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// EeveeSpotify's layers, ported, at the top of the Premium, ads & privacy page. Three switches, each off until asked for. Hide ads
-// keeps the ad services from starting (AdServices.x), takes ad components out of Home and Search
-// before they render (AdHubs.x, Feeds.m) and answers the requests behind them empty (AdNetwork.x).
-// Hide upsells drops the Premium prompts (AdPopups.x, AdServices.x) and forces the flags that show
-// them off (AdBlock.m, through Flags.x). Spoof Premium rewrites the product state and remote
-// config as they arrive (Premium.m), crossfade and automix included (Crossfade.x), and keeps the
-// session alive when the server disagrees (AdNetwork.x). The two Search switches force their flags
-// off (AdBlock.m, through Flags.x).
-#import <UIKit/UIKit.h>
-
-#define SGKeyHideAds @"spotifyglass.adblock.ads"
-#define SGKeyHideUpsells @"spotifyglass.adblock.upsells"
-#define SGKeyFakePremium @"spotifyglass.adblock.premium"
-#define SGKeyHideSearchVideos @"spotifyglass.adblock.searchVideos"
-#define SGKeyHideSocialProof @"spotifyglass.adblock.socialProof"
-
-// What a switch turning Spoof Premium on is told first.
-extern NSString *const SGFakePremiumWarning;
-
-// A flag the ads or upsells switch forces off while it is on. Flags.x asks, and the row for it locks.
-BOOL SGAdBlockForcesFlagOff(NSString *key);
-
-// What the hooks stopped, by kind, for the counts under the switches (nil label for all of them).
-void SGAdBlockCountOne(NSString *label);
-NSArray<NSString *> *SGAdBlockLabels(void);
-NSUInteger SGAdBlockCount(NSString *label);
-void SGResetAdBlock(void);
-
-// Premium.m: the body of v1/customize, or the bootstrap message that wraps one, rewritten to a
-// Premium account's. nil when the bytes do not parse.
-NSData *SGPatchCustomize(NSData *body);
-NSData *SGPatchBootstrap(NSData *body);
-
-// Feeds.m: a browsita, casita or scrollsita feed with its ad sections taken out; nil when there
-// were none, or the bytes were not the shape expected.
-NSData *SGStripFeed(NSData *body);
-
-// The Premium, ads & privacy page: these switches, the ad flags they lock, telemetry, the counters.
-UIViewController *SGAdsSettingsPage(void);
diff --git a/tweak/Sources/Shared/AdBlock/AdBlock.m b/tweak/Sources/Shared/AdBlock/AdBlock.m
deleted file mode 100644
index 9dc1fb87..00000000
--- a/tweak/Sources/Shared/AdBlock/AdBlock.m
+++ /dev/null
@@ -1,110 +0,0 @@
-#import "Core/SGCore.h"
-#import "AdBlock.h"
-
-#pragma mark - flags
-
-// Both lists are EeveeSpotify's, kept to the flags this Spotify has.
-static NSString *const adFlags[] = {
- @"ios-feature-adonappopen.enabled",
- @"ios-feature-adonappopen.cta_card_enabled",
- @"ios-nowplaying-scroll-impl.unified_leavebehind_npv_scroll_music_enabled",
- @"ios-nowplaying-scroll-impl.unified_leavebehind_npv_scroll_podcast_enabled",
- @"ios-feature-embeddedplaylist.use_unified_leavebehind_fetch",
- @"ios-adsnowplaying-embeddednpv-impl.foreground_enabled",
- @"ios-adsnowplaying-embeddednpv-impl.music_track_change_enabled",
- @"ios-adsnowplaying-embeddednpv-impl.enable_ads_on_podcast",
- @"ios-feature-adsbase.enable_ads_connect_state_observer",
- @"ios-feature-adsbase.enable_minimal_preroll_management",
- @"ios-feature-adsnowplayingui.embedded_npv_video_show_with_canvas",
- @"ios-feature-adssponsoredcontext.sponsored_playlist_v2_enabled",
- @"ios-feature-adssponsoredcontext.sponsored_context_mismatch_aderror_enabled",
- @"ios-feature-adssponsoredcontextnpbattachment.sponsored_npb_slot_fetch_enabled",
-};
-
-static NSString *const upsellFlags[] = {
- @"ios-feature-shuffletoggleupsell.is_enabled_pt2",
- @"ios-feature-shuffletoggleupsell.linear_upsell_new_style_experiment_enabled",
- @"ios-feature-shuffletoggleupsell.play_modes_upsell_new_style_experiment_enabled",
- @"ios-feature-nowplaying-modes.video_first_shuffle_upsell_enabled",
- @"ios-jam-freeusershuffleupsellsheetpage-impl.free_user_shuffle_upsell_sheet_enabled",
- @"ios-jam-freeuserskipupsellpage-impl.free_user_skip_upsell_sheet_enabled",
- @"ios-jam-freehostedjamsupsell-impl.free_hosted_jams_upsell_enabled",
- @"ios-reinventfree-contextualupsellpremiumpromo-impl.is_promo_cta_enabled",
- @"ios-reinventfree-contextualupsellpremiumpromo-impl.show_time_cap_upsell_with_premium_badge",
- @"ios-reinventfree-controllerui-impl.enable_video_time_cap_upsell",
- @"ios-reinventfree-controllerui-impl.enable_video_time_cap_upsell_on_search",
- @"ios-reinventfree-timecappivot-impl.music_video_upsell_enabled",
- @"ios-settings-mediaqualitypageplugin-impl.is_gbb_upsell_enabled",
- @"ios-settings-mediaqualitypageplugin-impl.should_show_pigeon_upsell",
- @"ios-system-listeningparties.preview_ended_upsell_enabled",
-};
-
-static NSString *const socialProofFlags[] = {
- @"ios-feature-search.social_proof_playlist_enabled",
- @"ios-feature-search.social_proof_plays_in_search_enabled",
-};
-
-static BOOL listed(NSString *key, NSString *const list[], size_t count) {
- for (size_t i = 0; i < count; i++) {
- if ([key isEqualToString:list[i]]) return YES;
- }
- return NO;
-}
-
-BOOL SGAdBlockForcesFlagOff(NSString *key) {
- if (SGHidden(SGKeyHideAds) && listed(key, adFlags, sizeof(adFlags) / sizeof(adFlags[0]))) return YES;
- if (SGHidden(SGKeyHideSearchVideos) && [key isEqualToString:@"ios-feature-search.video_carousel_section_enabled"]) return YES;
- if (SGHidden(SGKeyHideSocialProof) && listed(key, socialProofFlags, sizeof(socialProofFlags) / sizeof(socialProofFlags[0]))) return YES;
- return SGHidden(SGKeyHideUpsells) && listed(key, upsellFlags, sizeof(upsellFlags) / sizeof(upsellFlags[0]));
-}
-
-// After an override from the All flags page, and locking the rows that would turn the same flag off.
-__attribute__((constructor)) static void registerForcer(void) {
- SGFlagForcer off = ^id(NSString *key) { return SGAdBlockForcesFlagOff(key) ? @NO : nil; };
- SGRegisterFlagForcer(NO, off, off);
-}
-
-#pragma mark - counters
-
-static NSString *const kCounts = @"spotifyglass.adblock.counts";
-static NSString *const labels[] = {
- @"Ad services", @"Upsell services", @"Popups", @"Page components", @"Feed sections", @"Requests", @"Config rewrites",
-};
-static NSMutableDictionary<NSString *, NSNumber *> *sg_counts;
-
-// Counting happens on whichever thread the hook ran on, the page reads on the main one.
-static NSMutableDictionary<NSString *, NSNumber *> *countsLocked(void) {
- if (!sg_counts) {
- sg_counts = [[NSUserDefaults.standardUserDefaults dictionaryForKey:kCounts] mutableCopy] ?: [NSMutableDictionary dictionary];
- }
- return sg_counts;
-}
-
-void SGAdBlockCountOne(NSString *label) {
- @synchronized (kCounts) {
- NSMutableDictionary<NSString *, NSNumber *> *counts = countsLocked();
- counts[label] = @(counts[label].unsignedIntegerValue + 1);
- [NSUserDefaults.standardUserDefaults setObject:counts forKey:kCounts];
- }
-}
-
-NSArray<NSString *> *SGAdBlockLabels(void) {
- return [NSArray arrayWithObjects:labels count:sizeof(labels) / sizeof(labels[0])];
-}
-
-NSUInteger SGAdBlockCount(NSString *label) {
- @synchronized (kCounts) {
- NSDictionary<NSString *, NSNumber *> *counts = countsLocked();
- if (label) return counts[label].unsignedIntegerValue;
- NSUInteger total = 0;
- for (NSNumber *count in counts.allValues) total += count.unsignedIntegerValue;
- return total;
- }
-}
-
-void SGResetAdBlock(void) {
- @synchronized (kCounts) {
- sg_counts = [NSMutableDictionary dictionary];
- [NSUserDefaults.standardUserDefaults removeObjectForKey:kCounts];
- }
-}
diff --git a/tweak/Sources/Shared/AdBlock/AdBlockSettings.m b/tweak/Sources/Shared/AdBlock/AdBlockSettings.m
deleted file mode 100644
index d80e0459..00000000
--- a/tweak/Sources/Shared/AdBlock/AdBlockSettings.m
+++ /dev/null
@@ -1,69 +0,0 @@
-#import "Settings/SGModPage.h"
-#import "AdBlock.h"
-#import "Shared/Privacy/Privacy.h"
-
-NSString *const SGFakePremiumWarning = @"This is the part of EeveeSpotify Spotify's takedown went after, and it has not been tested here. It can end in a forced logout or worse for the account. A Premium account gains nothing from it.";
-
-// Every switch here forces a flag Spotify ships on to off, so the titles name the blocking: on stops
-// the thing, off is Spotify's own value. Hide ads and Hide upsells already force the first two
-// sections off, which locks those rows.
-static UIViewController *adFlagsPage(void) {
- return [[SGModPage alloc] initWithTitle:@"Ad and upsell flags" intro:SGRestartNote sections:@[
- SGNotedSection(@"Ads", @[
- SGKillRow(@"Block the ad when the app opens", @"ios-feature-adonappopen.enabled"),
- SGKillRow(@"Block its CTA card", @"ios-feature-adonappopen.cta_card_enabled"),
- ], @"Locked while Hide ads is on."),
- SGNotedSection(@"Upsells", @[
- SGKillRow(@"Hide the shuffle toggle upsell", @"ios-feature-shuffletoggleupsell.is_enabled_pt2"),
- SGKillRow(@"Hide the shuffle upsell in the video player", @"ios-feature-nowplaying-modes.video_first_shuffle_upsell_enabled"),
- ], @"Locked while Hide upsells is on."),
- SGSection(@"Reduce interventions", @[
- SGFlagRow(@"Reduce interventions", @"ios-messaging-reduceinterventions-impl.enabled"),
- ]),
- SGSection(@"Tooltips", @[
- SGKillRow(@"Hide the smart shuffle helper", @"ios-messaging-reduceinterventions-impl.enable_message_smart_shuffle_helper_tooltip"),
- SGKillRow(@"Hide the data saver tip", @"ios-feature-nowplayingbar.data_saver_tooltip"),
- SGKillRow(@"Hide the player suggestions upsell", @"ios-messaging-reduceinterventions-impl.enable_message_reinvent_free_n_p_v_suggestions_upsell"),
- SGKillRow(@"Hide the AI playlist creation tip", @"ios-messaging-reduceinterventions-impl.enable_message_your_library_ai_playlist_creation_tooltip"),
- SGKillRow(@"Hide the watch feed explorer tip", @"ios-messaging-reduceinterventions-impl.enable_message_watch_feed_entity_explorer_tooltip"),
- SGKillRow(@"Hide the account switching tip", @"ios-messaging-reduceinterventions-impl.enable_message_account_switching_tooltip"),
- SGKillRow(@"Hide the concert notifications tip", @"ios-messaging-reduceinterventions-impl.enable_message_live_events_concert_notifications_tooltip"),
- SGKillRow(@"Hide the live event tip", @"ios-messaging-reduceinterventions-impl.enable_message_live_events_event_entity_safe_tooltip"),
- SGKillRow(@"Hide the live event venue tip", @"ios-messaging-reduceinterventions-impl.enable_message_live_events_event_entity_venuename_header_tooltip"),
- SGKillRow(@"Hide the Puffin nudge", @"ios-messaging-reduceinterventions-impl.enable_message_puffin_nudge_end_optimization"),
- ]),
- ] footer:nil];
-}
-
-// The switches first and what they have stopped last, so the counters bury no setting.
-UIViewController *SGAdsSettingsPage(void) {
- NSMutableArray<SGModRow *> *counts = [NSMutableArray array];
- for (NSString *label in SGAdBlockLabels()) {
- [counts addObject:SGStatRow(label, ^NSString *{
- return @(SGAdBlockCount(label)).stringValue;
- })];
- }
- [counts addObject:SGStatRow(@"Total", ^NSString *{
- return @(SGAdBlockCount(nil)).stringValue;
- })];
- [counts addObject:SGActionRow(@"Reset the counters", nil, ^{ SGResetAdBlock(); })];
-
- SGModRow *fakePremium = SGOptionRow(@"Spoof Premium", nil, SGKeyFakePremium);
- fakePremium.warning = SGFakePremiumWarning;
-
- return [[SGModPage alloc] initWithTitle:@"Premium, ads & privacy" intro:SGRestartNote sections:@[
- SGNotedSection(@"Ads", @[
- SGWithSymbol(SGOptionRow(@"Hide ads", nil, SGKeyHideAds), @"speaker.slash"),
- SGWithSymbol(SGOptionRow(@"Hide upsells", nil, SGKeyHideUpsells), @"hand.raised"),
- SGWithSymbol(SGOptionRow(@"Hide the video carousel in Search", nil, SGKeyHideSearchVideos), @"play.rectangle.on.rectangle"),
- SGWithSymbol(SGOptionRow(@"Hide social proof in Search", nil, SGKeyHideSocialProof), @"person.2"),
- SGWithSymbol(SGPageRow(@"Ad and upsell flags", ^UIViewController *{ return adFlagsPage(); }), @"flag"),
- ], @"Audio ads between songs need Spoof Premium."),
- SGNotedSection(@"Premium", @[
- SGWithSymbol(fakePremium, @"crown"),
- ], @"Free accounts only."),
- SGPrivacySection(),
- SGSection(@"Ads blocked so far", counts),
- SGPrivacyCountersSection(),
- ] footer:nil];
-}
diff --git a/tweak/Sources/Shared/AdBlock/AdHubs.x b/tweak/Sources/Shared/AdBlock/AdHubs.x
deleted file mode 100644
index b9dbda1c..00000000
--- a/tweak/Sources/Shared/AdBlock/AdHubs.x
+++ /dev/null
@@ -1,120 +0,0 @@
-// Ad components taken out of the Hub JSON Home, Browse and Search pages are built from, before
-// the builder renders them (EeveeSpotify's HubsAdBlocker). A component is an ad when its
-// namespace, name, id, type or the keys of its metadata, logging or custom dictionaries say so;
-// its title never counts, "Billboard Hot 100" is a playlist. The plain ad words go with the ads
-// switch, a promotion word next to a surface word with the upsells one.
-#import "Core/SGCore.h"
-#import "AdBlock.h"
-
-// Bare "ad" and "ads" are absent on purpose: as substrings they hit made-for-you and release-radar.
-static NSString *const adWords[] = {
- @"sponsored", @"upsell", @"campaign", @"promoted", @"premium-upsell", @"billboard", @"interstitial", @"marquee",
- @"leavebehind", @"leave-behind", @"displayad", @"display-ad", @"fullbleed", @"full-bleed", @"leaderboard",
- @"advertisement", @"sponsor", @"native-ad", @"mobile-ads", @"on-surface", @"onsurface", @"search-ad", @"home-ad",
- @"sponsored-content", @"sponsored-ad", @"ad-card", @"native-ad-home-shelf", @"sponsored-shelf", @"sponsored-row",
- @"ad-shelf", @"ad-row", @"sponsored-item", @"ad-item", @"upgrade-component", @"mobile-display-ad-card",
- @"mobile-ads-display-ad-element",
-};
-static NSString *const intentWords[] = {@"premium", @"upgrade", @"offer", @"marketing", @"promo", @"promotion", @"subscribe", @"subscription"};
-static NSString *const surfaceWords[] = {@"banner", @"card", @"popup", @"pop-up", @"sheet", @"overlay", @"component", @"message"};
-
-#define COUNT(list) (sizeof(list) / sizeof(list[0]))
-
-static BOOL ads, upsells;
-
-static BOOL containsAny(NSString *text, NSString *const words[], size_t count) {
- for (size_t i = 0; i < count; i++) {
- if ([text containsString:words[i]]) return YES;
- }
- return NO;
-}
-
-static BOOL adWord(NSString *text) {
- if (![text isKindOfClass:NSString.class]) return NO;
- text = text.lowercaseString;
- if (ads && containsAny(text, adWords, COUNT(adWords))) return YES;
- return upsells && containsAny(text, intentWords, COUNT(intentWords)) && containsAny(text, surfaceWords, COUNT(surfaceWords));
-}
-
-static BOOL anyKey(NSDictionary *dictionary) {
- if (![dictionary isKindOfClass:NSDictionary.class]) return NO;
- for (NSString *key in dictionary) {
- if (adWord(key)) return YES;
- }
- return NO;
-}
-
-static BOOL isAd(NSDictionary *component) {
- id kind = component[@"component"];
- if ([kind isKindOfClass:NSDictionary.class]) {
- NSString *ns = kind[@"namespace"], *name = kind[@"name"];
- if (adWord(ns) || adWord(name) || adWord([NSString stringWithFormat:@"%@:%@", ns, name])) return YES;
- } else if (adWord(kind)) {
- return YES;
- }
- if (adWord(component[@"id"]) || adWord(component[@"type"])) return YES;
- NSDictionary *metadata = component[@"metadata"];
- if ([metadata isKindOfClass:NSDictionary.class]) {
- for (NSString *key in @[@"ad", @"is_ad", @"is_sponsored"]) {
- if ([metadata[key] respondsToSelector:@selector(boolValue)] && [metadata[key] boolValue]) return YES;
- }
- }
- if (anyKey(metadata) || anyKey(component[@"custom"])) return YES;
- NSDictionary *logging = component[@"logging"];
- return [logging isKindOfClass:NSDictionary.class] && (adWord(logging[@"type"]) || anyKey(logging));
-}
-
-static NSArray *filtered(NSArray *components) {
- if (![components isKindOfClass:NSArray.class]) return components;
- NSMutableArray *kept = [NSMutableArray array];
- for (NSDictionary *component in components) {
- if (![component isKindOfClass:NSDictionary.class]) {
- [kept addObject:component];
- continue;
- }
- if (isAd(component)) {
- SGAdBlockCountOne(@"Page components");
- SGLog(@"dropped page component %@", component[@"id"] ?: component[@"component"]);
- continue;
- }
- NSMutableDictionary *copy = [component mutableCopy];
- for (NSString *key in @[@"children", @"rows", @"body"]) {
- if (copy[key]) copy[key] = filtered(copy[key]);
- }
- [kept addObject:copy];
- }
- return kept;
-}
-
-%hook HUBViewModelBuilderImplementation
-- (void)addJSONDictionary:(NSDictionary *)dictionary {
- if (![dictionary isKindOfClass:NSDictionary.class]) {
- %orig;
- return;
- }
- NSMutableDictionary *copy = [dictionary mutableCopy];
- for (NSString *key in @[@"body", @"overlays", @"sections"]) {
- if (copy[key]) copy[key] = filtered(copy[key]);
- }
- NSDictionary *header = copy[@"header"];
- if ([header isKindOfClass:NSDictionary.class]) {
- if (isAd(header)) {
- SGAdBlockCountOne(@"Page components");
- [copy removeObjectForKey:@"header"];
- } else if (header[@"children"]) {
- NSMutableDictionary *headerCopy = [header mutableCopy];
- headerCopy[@"children"] = filtered(header[@"children"]);
- copy[@"header"] = headerCopy;
- }
- }
- %orig(copy);
-}
-%end
-
-%ctor {
- ads = SGHidden(SGKeyHideAds);
- upsells = SGHidden(SGKeyHideUpsells);
- if (!ads && !upsells) return;
- %init;
- SGRequireClasses(@[@"HUBViewModelBuilderImplementation"]);
-}
diff --git a/tweak/Sources/Shared/AdBlock/AdNetwork.x b/tweak/Sources/Shared/AdBlock/AdNetwork.x
deleted file mode 100644
index 1af3d3cc..00000000
--- a/tweak/Sources/Shared/AdBlock/AdNetwork.x
+++ /dev/null
@@ -1,291 +0,0 @@
-// Spotify's responses on their way in, through the URLSession delegates it reads them by:
-// SPTDataLoaderService for most of spclient, HttpClientURLSession for what some regions route the
-// other way. A request for an ad is answered empty. With Spoof Premium on, the bootstrap
-// and customize bodies are rewritten by Premium.m before the client sees them, the endpoints the
-// server would use to log the account out are answered as if they succeeded, and past the first
-// thirty seconds the re-fetches that could bring the real state back are cancelled before they
-// leave. Feeds go through Feeds.m. Everything here is EeveeSpotify's, less its Ably hooks, which
-// it does not turn on for 9.1 either.
-#import "Core/SGCore.h"
-#import "AdBlock.h"
-
-static BOOL ads, premium;
-static NSDate *started;
-static NSObject *cacheLock;
-static NSData *cachedCustomize; // the last rewritten customize body, for a 304 and the re-fetches
-static char kBufferKey, kServedKey, kPassKey;
-
-typedef NS_ENUM(NSInteger, SGNet) { SGNetPass, SGNetBlock, SGNetPatch };
-
-static NSTimeInterval elapsed(void) {
- return -started.timeIntervalSinceNow;
-}
-
-static BOOL has(NSString *text, NSString *needle) {
- return [text containsString:needle];
-}
-
-static BOOL isBootstrap(NSString *path) { return has(path, @"v1/bootstrap"); }
-static BOOL isCustomize(NSString *path) { return has(path, @"v1/customize"); }
-
-// The feeds Home, Search and the page under the player are built from. casita/v1/feeds is the flat
-// list of tab chips, not sections.
-static BOOL isFeed(NSString *path) {
- if (has(path, @"/casita/v1/feeds")) return NO;
- return has(path, @"/browsita/") || has(path, @"/casita/") || has(path, @"/scrollsita/");
-}
-
-static BOOL isLogout(NSString *path) {
- return has(path, @"logout") || has(path, @"sign-out") || has(path, @"session/purge") || has(path, @"token/revoke")
- || has(path, @"auth/expire") || (has(path, @"melody") && has(path, @"check")) || has(path, @"product-state")
- || (has(path, @"license") && has(path, @"check")) || has(path, @"deletetoken");
-}
-
-static NSString *const adPaths[] = {
- @"/ads/", @"/ad-logic/", @"/dac/view/v1/", @"/ad-slot/", @"/ad-inventory/", @"/ad-on-app-open", @"/sponsored/",
- @"/promoted/", @"/upsell/", @"/premium-upsell", @"/upsell-banner", @"/upsell-card", @"/referrals/upsell",
- @"/campaign/", @"/billboard/", @"/banner/", @"/interstitial/", @"/overlay/", @"/popup/", @"/pop-up/",
- @"/search-ad/", @"/home-ad/", @"/marquee/", @"/leavebehind", @"/leave-behind", @"/display-ad/", @"/fullbleed/",
- @"/leaderboard/", @"/ad-card/", @"/sponsored-content/", @"/sponsored-ad/", @"/native-ad/", @"/sponsored-shelf/",
- @"/sponsored-row/", @"/ad-shelf/", @"/ad-row/", @"/sponsored-item/", @"/ad-item/", @"/merchandising/",
- @"/upgrade-component/", @"/marketing/", @"/home-ads/", @"/search-ads/",
-};
-
-static BOOL isAd(NSURL *url, NSString *path) {
- for (size_t i = 0; i < sizeof(adPaths) / sizeof(adPaths[0]); i++) {
- if (has(path, adPaths[i])) return YES;
- }
- if (has(path, @"/esperanto/") && (has(path, @"ad") || has(path, @"slot"))) return YES;
- NSString *host = url.host.lowercaseString ?: @"";
- return has(host, @"doubleclick") || has(host, @"googlesyndication") || [host hasPrefix:@"aet."]
- || [@[@"ad.spotify.com", @"ads.spotify.com", @"aet.spotify.com"] containsObject:host];
-}
-
-// The first thirty seconds are a fresh login's: signup/public and customize are part of it, and
-// answering them broke first launch.
-static BOOL isRefetch(NSString *path) {
- return has(path, @"signup/public") || has(path, @"select-ondemand-set") || has(path, @"trials-facade/start-trial")
- || has(path, @"premium-marketing/upselloffer") || (has(path, @"pendragon") && has(path, @"fetchmessagelist"))
- || has(path, @"pushka-tokens") || has(path, @"apresolve") || has(path, @"pses/screenconfig") || isCustomize(path);
-}
-
-static SGNet classify(NSURL *url) {
- NSString *path = url.path.lowercaseString ?: @"";
- if (premium && isLogout(path)) return SGNetBlock;
- if (ads && isAd(url, path)) return SGNetBlock;
- if (premium && elapsed() > 30 && isRefetch(path)) return SGNetBlock;
- if (premium && (isBootstrap(path) || isCustomize(path))) return SGNetPatch;
- if (ads && isFeed(path)) return SGNetPatch;
- return SGNetPass;
-}
-
-static NSData *cached(void) {
- @synchronized (cacheLock) { return cachedCustomize; }
-}
-
-static NSData *json(NSString *text) {
- return [text dataUsingEncoding:NSUTF8StringEncoding];
-}
-
-// The body a blocked request is answered with: what its reader parses for, so that nothing is
-// retried and no logout path taken.
-static NSData *blockedReply(NSString *path) {
- if (has(path, @"signup/public")) return json(@"{\"status\":1,\"country\":\"US\",\"is_country_launched\":true}");
- if (has(path, @"trials-facade")) return json(@"{\"result\":\"NOT_ELIGIBLE\"}");
- if (has(path, @"premium-marketing") || has(path, @"pses/screenconfig")) return json(@"{}");
- if (isLogout(path) || has(path, @"apresolve")) return json(@"{\"status\":\"OK\"}");
- if (isCustomize(path) && cached()) return cached();
- return [NSData data];
-}
-
-static NSData *patched(NSURL *url, NSData *body) {
- NSString *path = url.path.lowercaseString ?: @"";
- if (isFeed(path)) return SGStripFeed(body);
- NSData *result = isBootstrap(path) ? SGPatchBootstrap(body) : SGPatchCustomize(body);
- if (!result) {
- SGLog(@"could not rewrite %@, passed through", path);
- return nil;
- }
- if (isCustomize(path)) {
- @synchronized (cacheLock) { cachedCustomize = result; }
- }
- SGAdBlockCountOne(@"Config rewrites");
- SGLog(@"rewrote %@, %lu -> %lu bytes", path, (unsigned long)body.length, (unsigned long)result.length);
- return result;
-}
-
-#pragma mark - the delegate's three calls
-
-// Data handed to the delegate by the mod goes through its hooked didReceiveData like Spotify's own,
-// with the pass mark on the task so the hook lets it by.
-static void deliver(id<NSURLSessionDataDelegate> delegate, NSURLSession *session, NSURLSessionTask *task, NSData *data) {
- objc_setAssociatedObject(task, &kPassKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- [delegate URLSession:session dataTask:(NSURLSessionDataTask *)task didReceiveData:data];
- objc_setAssociatedObject(task, &kPassKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
-}
-
-// A customize the server says has not changed, answered with the rewritten one from last time.
-static NSHTTPURLResponse *replayFor(NSURLSessionTask *task, NSURLResponse *response) {
- if (!premium || ![response isKindOfClass:NSHTTPURLResponse.class] || ((NSHTTPURLResponse *)response).statusCode != 304) return nil;
- NSURL *url = task.currentRequest.URL;
- if (!isCustomize(url.path.lowercaseString ?: @"") || !cached()) return nil;
- objc_setAssociatedObject(task, &kServedKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- return [[NSHTTPURLResponse alloc] initWithURL:url statusCode:200 HTTPVersion:@"HTTP/2.0" headerFields:@{}];
-}
-
-// YES when the data is not the delegate's to see yet: dropped for a blocked request, kept back for
-// one whose reply is rewritten when it finishes.
-static BOOL holds(NSURLSessionTask *task, NSData *data) {
- if (objc_getAssociatedObject(task, &kPassKey)) return NO;
- switch (classify(task.currentRequest.URL)) {
- case SGNetBlock:
- return YES;
- case SGNetPatch: {
- NSMutableData *buffer = objc_getAssociatedObject(task, &kBufferKey);
- if (!buffer) objc_setAssociatedObject(task, &kBufferKey, (buffer = [NSMutableData data]), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- [buffer appendData:data];
- return YES;
- }
- default:
- return NO;
- }
-}
-
-static void complete(id<NSURLSessionDataDelegate> delegate, NSURLSession *session, NSURLSessionTask *task, NSError *error, void (^finish)(NSError *)) {
- NSURL *url = task.currentRequest.URL;
- NSString *path = url.path.lowercaseString ?: @"";
- NSMutableData *buffer = objc_getAssociatedObject(task, &kBufferKey);
- objc_setAssociatedObject(task, &kBufferKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- if (objc_getAssociatedObject(task, &kServedKey)) {
- finish(nil);
- return;
- }
- switch (classify(url)) {
- case SGNetBlock:
- SGAdBlockCountOne(@"Requests");
- SGLog(@"answered %@ empty", path);
- deliver(delegate, session, task, blockedReply(path));
- finish(nil);
- return;
- case SGNetPatch:
- if (error) {
- finish(error);
- return;
- }
- // Nothing to rewrite: a 304, or a body of no bytes. The delegate is told of a body either
- // way, since a completion with none hangs some readers.
- if (!buffer) {
- deliver(delegate, session, task, (isCustomize(path) ? cached() : nil) ?: [NSData data]);
- finish(nil);
- return;
- }
- deliver(delegate, session, task, patched(url, buffer) ?: buffer);
- finish(nil);
- return;
- default:
- finish(error);
- }
-}
-
-%hook SPTDataLoaderService
-- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)task didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))handler {
- NSHTTPURLResponse *replay = replayFor(task, response);
- %orig(session, task, replay ?: response, handler);
- if (replay) deliver((id)self, session, task, cached());
-}
-- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)task didReceiveData:(NSData *)data {
- if (!holds(task, data)) %orig;
-}
-- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {
- complete((id)self, session, task, error, ^(NSError *passed) { %orig(session, task, passed); });
-}
-%end
-
-%hook _TtC26Connectivity_HttpClientKit20HttpClientURLSession
-- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)task didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))handler {
- NSHTTPURLResponse *replay = replayFor(task, response);
- %orig(session, task, replay ?: response, handler);
- if (replay) deliver((id)self, session, task, cached());
-}
-- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)task didReceiveData:(NSData *)data {
- if (!holds(task, data)) %orig;
-}
-- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {
- complete((id)self, session, task, error, ^(NSError *passed) { %orig(session, task, passed); });
-}
-%end
-
-#pragma mark - before a request leaves
-
-// The re-fetches that could put the real product state back, or drop the push token, use sessions
-// of their own that the delegate hooks do not see; they are cancelled at the task. login5 and the
-// Google token stay: blocking those was a crash loop.
-%group Premium
-%hook NSURLSessionTask
-- (void)resume {
- NSURL *url = self.currentRequest.URL ?: self.originalRequest.URL;
- NSString *host = url.host.lowercaseString ?: @"", *path = url.path.lowercaseString ?: @"";
- BOOL spotify = has(host, @"spotify") || has(host, @"spclient");
- if (spotify && elapsed() > 30 && (has(path, @"deletetoken") || has(path, @"signup/public") || has(path, @"pses/screenconfig")
- || isCustomize(path) || has(host, @"apresolve"))) {
- SGAdBlockCountOne(@"Requests");
- SGLog(@"cancelled %@%@ before it left", host, path);
- [self cancel];
- return;
- }
- %orig;
-}
-%end
-%end
-
-// The config comes back 304 with no body when the app holds a copy of it and asks whether that is still
-// current, and a copy taken while Spoof Premium was off is the server's own: the mod then has nothing to
-// rewrite, and the account stays free until the server changes the config (device 2026-09-21). So the two
-// go out without the question, and the server always answers in full.
-static NSURLRequest *unconditional(NSURLRequest *request) {
- NSString *host = request.URL.host.lowercaseString ?: @"", *path = request.URL.path.lowercaseString ?: @"";
- if (!(has(host, @"spotify") || has(host, @"spclient")) || !(isBootstrap(path) || isCustomize(path))) return nil;
- if (![request valueForHTTPHeaderField:@"If-None-Match"] && ![request valueForHTTPHeaderField:@"If-Modified-Since"]) return nil;
- NSMutableURLRequest *plain = [request mutableCopy];
- [plain setValue:nil forHTTPHeaderField:@"If-None-Match"];
- [plain setValue:nil forHTTPHeaderField:@"If-Modified-Since"];
- plain.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
- SGLog(@"premium: %@ sent without its validators", path);
- return plain;
-}
-
-%group PremiumRequests
-%hook NSURLSession
-- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request {
- return %orig(unconditional(request) ?: request);
-}
-%end
-%end
-
-// The sessions Spotify makes are __NSURLSessionLocal; hooked as well only when that class answers
-// dataTaskWithRequest: itself, since a hook on an inherited method would sit on NSURLSession's twice.
-%group PremiumLocalRequests
-%hook __NSURLSessionLocal
-- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request {
- return %orig(unconditional(request) ?: request);
-}
-%end
-%end
-
-%ctor {
- ads = SGHidden(SGKeyHideAds);
- premium = SGHidden(SGKeyFakePremium);
- if (!ads && !premium) return;
- started = NSDate.date;
- cacheLock = [NSObject new];
- %init;
- if (premium) {
- %init(Premium);
- %init(PremiumRequests);
- SEL selector = @selector(dataTaskWithRequest:);
- Class local = objc_getClass("__NSURLSessionLocal");
- Method own = local ? class_getInstanceMethod(local, selector) : NULL;
- if (own && own != class_getInstanceMethod(NSURLSession.class, selector)) %init(PremiumLocalRequests);
- }
- SGRequireClasses(@[@"SPTDataLoaderService", @"_TtC26Connectivity_HttpClientKit20HttpClientURLSession"]);
-}
diff --git a/tweak/Sources/Shared/AdBlock/AdPopups.x b/tweak/Sources/Shared/AdBlock/AdPopups.x
deleted file mode 100644
index 2cfaa108..00000000
--- a/tweak/Sources/Shared/AdBlock/AdPopups.x
+++ /dev/null
@@ -1,72 +0,0 @@
-// The Premium prompts Spotify presents as Encore pop-ups, dropped when their words sell Premium
-// (EeveeSpotify's UpsellPopupBlocker). The words are read where the dialog model is made, since
-// the dialog handed to the presenter does not expose them on every build; the presenter reads
-// them itself as a fallback.
-#import "Core/SGCore.h"
-#import "AdBlock.h"
-
-static NSString *const words[] = {
- @"premium", @"upgrade", @"subscribe", @"subscription", @"listening without limits", @"unlimited skips",
- @"play the songs you love", @"go premium", @"like listening", @"free account", @"ad-free", @"ad free", @"try free",
- @"get premium", @"start premium", @"upsell", @"paywall", @"free tier", @"limited listening",
- @"předplatn", @"bez reklam",
-};
-
-static char kUpsellKey;
-
-static BOOL sells(NSString *text) {
- if (![text isKindOfClass:NSString.class]) return NO;
- text = text.lowercaseString;
- for (size_t i = 0; i < sizeof(words) / sizeof(words[0]); i++) {
- if ([text containsString:words[i]]) return YES;
- }
- return NO;
-}
-
-static void mark(id object) {
- objc_setAssociatedObject(object, &kUpsellKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
-}
-
-static BOOL marked(id object) {
- return objc_getAssociatedObject(object, &kUpsellKey) != nil;
-}
-
-// valueForKey: on a key the object lacks raises, so it is only asked what it answers to.
-static id readKey(id object, NSString *key) {
- return [object respondsToSelector:NSSelectorFromString(key)] ? [object valueForKey:key] : nil;
-}
-
-%hook SPTEncorePopUpDialogModel
-- (id)initWithTitle:(NSString *)title description:(NSString *)description image:(id)image primaryButtonTitle:(NSString *)primary secondaryButtonTitle:(NSString *)secondary {
- id model = %orig;
- if (model && (sells(title) || sells(description) || sells(primary) || sells(secondary))) mark(model);
- return model;
-}
-%end
-
-%hook SPTEncorePopUpDialog
-- (void)update:(id)model {
- if (marked(model)) mark(self);
- %orig;
-}
-%end
-
-%hook SPTEncorePopUpPresenter
-- (void)presentPopUp:(id)popUp {
- id model = readKey(popUp, @"model") ?: popUp;
- NSString *title = readKey(model, @"title") ?: readKey(model, @"dialogTitle");
- NSString *body = readKey(model, @"descriptionText") ?: readKey(model, @"body") ?: readKey(model, @"subtitle");
- if (marked(popUp) || sells(title) || sells(body)) {
- SGAdBlockCountOne(@"Popups");
- SGLog(@"dropped pop-up %@", title ?: @"(marked at its model)");
- return;
- }
- %orig;
-}
-%end
-
-%ctor {
- if (!SGHidden(SGKeyHideUpsells)) return;
- %init;
- SGRequireClasses(@[@"SPTEncorePopUpDialogModel", @"SPTEncorePopUpDialog", @"SPTEncorePopUpPresenter"]);
-}
diff --git a/tweak/Sources/Shared/AdBlock/AdServices.x b/tweak/Sources/Shared/AdBlock/AdServices.x
deleted file mode 100644
index 77a1f212..00000000
--- a/tweak/Sources/Shared/AdBlock/AdServices.x
+++ /dev/null
@@ -1,126 +0,0 @@
-// The services behind every ad surface and Premium prompt, each an SPTService Spotify starts by
-// sending it -load. Hooked to do nothing, the surface is never built: the brand ad on Home, the card
-// under the player, the sponsored playlist header, the sponsorship on the now playing bar, the
-// in-stream ad, and the sheets and cards that sell Premium. The two views are a fallback for a
-// header or banner already on screen before its service was silenced.
-#import "Core/SGCore.h"
-#import "AdBlock.h"
-
-static void takeDown(UIView *view) {
- view.hidden = YES;
- view.userInteractionEnabled = NO;
- if (view.superview) [view removeFromSuperview];
-}
-
-%group Ads
-
-%hook _TtC19AdsPlatform_AdsImpl14AdsServiceImpl
-- (void)load { SGAdBlockCountOne(@"Ad services"); }
-%end
-%hook _TtC29AdsNowPlaying_InStreamAdsImpl18InStreamAdsService
-- (void)load { SGAdBlockCountOne(@"Ad services"); }
-%end
-%hook _TtC29AdsNowPlaying_EmbeddedNPVImpl22EmbeddedNPVServiceImpl
-- (void)load { SGAdBlockCountOne(@"Ad services"); }
-%end
-%hook _TtC36AdsStandalone_LeavebehindAdsBaseImpl25LeavebehindAdsBaseService
-- (void)load { SGAdBlockCountOne(@"Ad services"); }
-%end
-%hook _TtC36AdsStandalone_LeavebehindAdsBaseImpl33LeavebehindAdsBaseInternalService
-- (void)load { SGAdBlockCountOne(@"Ad services"); }
-%end
-%hook _TtC35AdsEmbedded_AdsSponsoredContextImpl30AdsSponsoredContextServiceImpl
-- (void)load { SGAdBlockCountOne(@"Ad services"); }
-%end
-%hook _TtC48AdsEmbedded_AdsSponsoredContextNPBAttachmentImpl43AdsSponsoredContextNPBAttachmentServiceImpl
-- (void)load { SGAdBlockCountOne(@"Ad services"); }
-%end
-%hook _TtC42AdsEmbedded_AdsSponsoredPlaylistHeaderImpl37AdsSponsoredPlaylistHeaderServiceImpl
-- (void)load { SGAdBlockCountOne(@"Ad services"); }
-%end
-%hook _TtC20NativeAds_LoggerImpl26NativeAdsLoggerServiceImpl
-- (void)load { SGAdBlockCountOne(@"Ad services"); }
-%end
-// The leavebehind card among the player's scroll cards. It has no -load; its card is added the way
-// lyrics and credits add theirs, so it is kept off the list instead.
-%hook _TtC32AdsEmbedded_EmbeddedCTACardsImpl23EmbeddedCTACardsService
-- (void)registerScrollProviderIn:(id)registry { SGAdBlockCountOne(@"Ad services"); }
-%end
-
-%hook _TtC18AdsPlatform_ECMKit37AdsSponsoredPlaylistHeaderCentralView
-- (void)didMoveToSuperview {
- %orig;
- takeDown((UIView *)self);
-}
-%end
-
-%end
-
-%group Upsells
-
-%hook _TtC19Upsells_ServiceImpl18UpsellsServiceImpl
-- (void)load { SGAdBlockCountOne(@"Upsell services"); }
-%end
-%hook _TtC31PremiumUpsell_UpsellServiceImpl17UpsellServiceImpl
-- (void)load { SGAdBlockCountOne(@"Upsell services"); }
-%end
-%hook _TtC45ReinventFree_ContextualUpsellPremiumPromoImpl39ContextualUpsellPremiumPromoServiceImpl
-- (void)load { SGAdBlockCountOne(@"Upsell services"); }
-%end
-%hook _TtC40Referrals_ReferralsUpsellCardElementImpl37ReferralsUpsellCardElementServiceImpl
-- (void)load { SGAdBlockCountOne(@"Upsell services"); }
-%end
-%hook _TtC31ReinventFree_DownloadUpsellImpl21DownloadUpsellService
-- (void)load { SGAdBlockCountOne(@"Upsell services"); }
-%end
-%hook _TtC28Jam_FreeHostedJamsUpsellImpl31FreeHostedJamsUpsellServiceImpl
-- (void)load { SGAdBlockCountOne(@"Upsell services"); }
-%end
-%hook _TtC30Jam_FreeUserSkipUpsellPageImpl29FreeUserSkipUpsellPageService
-- (void)load { SGAdBlockCountOne(@"Upsell services"); }
-%end
-%hook _TtC38Jam_FreeUserShuffleUpsellSheetPageImpl37FreeUserShuffleUpsellSheetPageService
-- (void)load { SGAdBlockCountOne(@"Upsell services"); }
-%end
-
-%hook _TtC13Upsells_UIKit29SelfLoadingUpsellBannerUIView
-- (void)didMoveToSuperview {
- %orig;
- takeDown((UIView *)self);
-}
-%end
-
-%end
-
-%ctor {
- if (SGHidden(SGKeyHideAds)) {
- %init(Ads);
- SGRequireClasses(@[
- @"_TtC19AdsPlatform_AdsImpl14AdsServiceImpl",
- @"_TtC29AdsNowPlaying_InStreamAdsImpl18InStreamAdsService",
- @"_TtC29AdsNowPlaying_EmbeddedNPVImpl22EmbeddedNPVServiceImpl",
- @"_TtC36AdsStandalone_LeavebehindAdsBaseImpl25LeavebehindAdsBaseService",
- @"_TtC36AdsStandalone_LeavebehindAdsBaseImpl33LeavebehindAdsBaseInternalService",
- @"_TtC35AdsEmbedded_AdsSponsoredContextImpl30AdsSponsoredContextServiceImpl",
- @"_TtC48AdsEmbedded_AdsSponsoredContextNPBAttachmentImpl43AdsSponsoredContextNPBAttachmentServiceImpl",
- @"_TtC42AdsEmbedded_AdsSponsoredPlaylistHeaderImpl37AdsSponsoredPlaylistHeaderServiceImpl",
- @"_TtC20NativeAds_LoggerImpl26NativeAdsLoggerServiceImpl",
- @"_TtC32AdsEmbedded_EmbeddedCTACardsImpl23EmbeddedCTACardsService",
- @"_TtC18AdsPlatform_ECMKit37AdsSponsoredPlaylistHeaderCentralView",
- ]);
- }
- if (SGHidden(SGKeyHideUpsells)) {
- %init(Upsells);
- SGRequireClasses(@[
- @"_TtC19Upsells_ServiceImpl18UpsellsServiceImpl",
- @"_TtC31PremiumUpsell_UpsellServiceImpl17UpsellServiceImpl",
- @"_TtC45ReinventFree_ContextualUpsellPremiumPromoImpl39ContextualUpsellPremiumPromoServiceImpl",
- @"_TtC40Referrals_ReferralsUpsellCardElementImpl37ReferralsUpsellCardElementServiceImpl",
- @"_TtC31ReinventFree_DownloadUpsellImpl21DownloadUpsellService",
- @"_TtC28Jam_FreeHostedJamsUpsellImpl31FreeHostedJamsUpsellServiceImpl",
- @"_TtC30Jam_FreeUserSkipUpsellPageImpl29FreeUserSkipUpsellPageService",
- @"_TtC38Jam_FreeUserShuffleUpsellSheetPageImpl37FreeUserShuffleUpsellSheetPageService",
- @"_TtC13Upsells_UIKit29SelfLoadingUpsellBannerUIView",
- ]);
- }
-}
diff --git a/tweak/Sources/Shared/AdBlock/Crossfade.x b/tweak/Sources/Shared/AdBlock/Crossfade.x
deleted file mode 100644
index ea71958a..00000000
--- a/tweak/Sources/Shared/AdBlock/Crossfade.x
+++ /dev/null
@@ -1,21 +0,0 @@
-// Crossfade under Spoof Premium (EeveeSpotify's): the fade engine reads the stored crossfade switch,
-// but the duration slider only writes the duration, so the fade stayed off at any length.
-#import "Core/SGCore.h"
-#import "AdBlock.h"
-
-@interface _TtC31Preferences_CorePreferencesImpl28SPTPreferencesImplementation : NSObject
-- (void)setAudioCrossfade:(BOOL)on;
-@end
-
-%hook _TtC31Preferences_CorePreferencesImpl28SPTPreferencesImplementation
-- (void)setAudioCrossfadeTime:(NSInteger)time {
- %orig;
- [self setAudioCrossfade:time > 0];
-}
-%end
-
-%ctor {
- if (!SGHidden(SGKeyFakePremium)) return;
- %init;
- SGRequireClasses(@[@"_TtC31Preferences_CorePreferencesImpl28SPTPreferencesImplementation"]);
-}
diff --git a/tweak/Sources/Shared/AdBlock/Feeds.m b/tweak/Sources/Shared/AdBlock/Feeds.m
deleted file mode 100644
index e38d30bb..00000000
--- a/tweak/Sources/Shared/AdBlock/Feeds.m
+++ /dev/null
@@ -1,65 +0,0 @@
-// Ad sections taken out of the feeds Home, Search and the page under the player are built from
-// (EeveeSpotify's BrowsitaSectionStripper). A feed is one container field of sections, each a
-// field 1 message; a section goes when its bytes name an ad, or a promotion and a surface for it.
-#import "Core/SGCore.h"
-#import "AdBlock.h"
-#import "Protobuf.h"
-
-static const char *const hardMarkers[] = {
- "spotify:ad:", "ad-formats", "advertisement", "brand-ad", "sponsored", "marquee", "promoted", "home-ads",
- "adsproduct", "leavebehind", "leave-behind", "premium-upsell", "premium_upsell", "premiumupsell",
- "referralsupsellcard",
-};
-static const char *const intentMarkers[] = {
- "upsell", "upgrade", "subscribe", "premium", "promo", "promotion", "marketing", "offer",
-};
-static const char *const surfaceMarkers[] = {
- "banner", "card", "popup", "pop-up", "sheet", "interstitial", "promotion", "promo",
-};
-// The filter chips of Search carry "browse" and "chip" in their ids and are never the ad.
-static const char *const keepMarkers[] = {"filter", "chip", "pillar", "browse:chips"};
-
-#define COUNT(list) (sizeof(list) / sizeof(list[0]))
-
-// ASCII, case-insensitive; the markers are lower case.
-static BOOL contains(NSData *data, const char *needle) {
- const uint8_t *bytes = data.bytes;
- size_t length = data.length, n = strlen(needle);
- for (size_t i = 0; i + n <= length; i++) {
- size_t k = 0;
- while (k < n && tolower(bytes[i + k]) == needle[k]) k++;
- if (k == n) return YES;
- }
- return NO;
-}
-
-static BOOL containsAny(NSData *data, const char *const markers[], size_t count) {
- for (size_t i = 0; i < count; i++) {
- if (contains(data, markers[i])) return YES;
- }
- return NO;
-}
-
-static BOOL adSection(NSData *section) {
- if (containsAny(section, hardMarkers, COUNT(hardMarkers))) return YES;
- if (containsAny(section, keepMarkers, COUNT(keepMarkers))) return NO;
- return containsAny(section, intentMarkers, COUNT(intentMarkers)) && containsAny(section, surfaceMarkers, COUNT(surfaceMarkers));
-}
-
-NSData *SGStripFeed(NSData *body) {
- NSMutableArray<SGPBField *> *fields = SGPBParse(body);
- SGPBField *container = fields.firstObject;
- if (container.number != 1 || container.wire != 2) return nil;
- NSMutableArray<SGPBField *> *sections = SGPBParse(container.payload);
- if (!sections) return nil;
- NSMutableArray<SGPBField *> *kept = [NSMutableArray array];
- for (SGPBField *section in sections) {
- if (section.number != 1 || section.wire != 2) return nil;
- if (adSection(section.payload)) SGAdBlockCountOne(@"Feed sections");
- else [kept addObject:section];
- }
- if (kept.count == sections.count) return nil;
- SGLog(@"dropped %lu of %lu feed sections", (unsigned long)(sections.count - kept.count), (unsigned long)sections.count);
- container.payload = SGPBSerialize(kept);
- return SGPBSerialize(fields);
-}
diff --git a/tweak/Sources/Shared/AdBlock/Premium.m b/tweak/Sources/Shared/AdBlock/Premium.m
deleted file mode 100644
index c55a3b75..00000000
--- a/tweak/Sources/Shared/AdBlock/Premium.m
+++ /dev/null
@@ -1,433 +0,0 @@
-// Spoof Premium: the UCS response, which carries the account's product state and its remote
-// config, rewritten as it arrives. The attributes and the flag rules are EeveeSpotify's. Offline,
-// audio quality and the social session attributes are left alone: the server still decides those,
-// and a spoofed one only shows UI the request behind it will fail.
-//
-// UcsResponse: 1 ResolveResponse { 1 ResolveConfiguration { 3 repeated AssignedValue } },
-// 3 AccountAttributesResponse { 1 repeated entry { 1 key, 2 AccountAttribute { 2 bool, 4 string } } }
-// AssignedValue: 1 { 1 scope, 2 name }, 3 BoolValue { 1 }, 4 IntValue { 1 }, 5 EnumValue { 1 }
-// A customize body is CustomizeMessage { 1 UcsResponse }; bootstrap wraps that in 2 { 1 { 1 { it } } }.
-#import "Core/SGCore.h"
-#import "AdBlock.h"
-#import "Protobuf.h"
-
-#pragma mark - account attributes
-
-// A string goes in as one, a number as a bool.
-static NSDictionary<NSString *, id> *forcedAttributes(void) {
- NSISO8601DateFormatter *iso = [NSISO8601DateFormatter new];
- iso.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
- NSString *yearOn = [iso stringFromDate:[NSCalendar.currentCalendar dateByAddingUnit:NSCalendarUnitYear value:1 toDate:NSDate.date options:0]];
- return @{
- @"ads": @NO,
- @"ab-ad-player-targeting": @"0",
- @"allow-advertising-id-transmission": @NO,
- @"restrict-advertising-id-transmission": @YES,
- @"can_use_superbird": @YES,
- @"enable-crossfade-product-state": @"1",
- @"enable-gapless-product-state": @"1",
- @"catalogue": @"premium",
- @"financial-product": @"pr:premium,tc:0",
- @"is-eligible-premium-unboxing": @YES,
- @"name": @"Spotify Premium",
- @"nft-disabled": @"1",
- @"on-demand": @YES,
- @"payments-initial-campaign": @"default",
- @"player-license": @"premium",
- @"player-license-v2": @"premium",
- @"product-expiry": yearOn,
- @"shuffle-eligible": @YES,
- @"streaming-rules": @"",
- @"subscription-enddate": yearOn,
- @"type": @"premium",
- @"unrestricted": @YES,
- @"high-bitrate": @YES,
- @"loudness-levels": @"1:-5.0,0.0,3.0:-2.0",
- @"pick-and-shuffle": @NO,
- @"mixing-tools": @"EDIT",
- @"your-library-tags": @YES,
- @"libspotify": @YES,
- @"mobile": @YES,
- };
-}
-
-// Attributes that would have the client validate the state against the server, or offer a trial.
-static NSString *const strippedAttributes[] = {
- @"payment-state", @"last-premium-activation-date", @"on-demand-trial", @"on-demand-trial-in-progress",
- @"smart-shuffle", @"at-signal", @"feature-set-id-masked", @"strider-key", @"is-eligible-for-trial",
- @"is-eligible-for-upsell", @"upsell-state", @"ad-session-persistence", @"ad-formats-preroll-video",
-};
-
-static BOOL stripped(NSString *key) {
- if ([key hasPrefix:@"is-premium-eligible"]) return YES;
- for (size_t i = 0; i < sizeof(strippedAttributes) / sizeof(strippedAttributes[0]); i++) {
- if ([key isEqualToString:strippedAttributes[i]]) return YES;
- }
- return NO;
-}
-
-static SGPBField *attributeEntry(NSString *key, id value) {
- SGPBField *attribute = [value isKindOfClass:NSString.class] ? SGPBString(4, value) : SGPBVarint(2, [value boolValue]);
- return SGPBBytes(1, SGPBSerialize(@[SGPBString(1, key), SGPBBytes(2, SGPBSerialize(@[attribute]))]));
-}
-
-static NSData *patchAttributes(NSData *response) {
- NSMutableArray<SGPBField *> *fields = SGPBParse(response);
- if (!fields) return nil;
- NSDictionary<NSString *, id> *forced = forcedAttributes();
- NSMutableArray<SGPBField *> *out = [NSMutableArray array];
- NSMutableSet<NSString *> *seen = [NSMutableSet set];
- for (SGPBField *field in fields) {
- NSString *key = field.number == 1 && field.wire == 2 ? SGPBText(SGPBFirst(SGPBParse(field.payload), 1)) : nil;
- if (!key || (!forced[key] && !stripped(key))) {
- [out addObject:field];
- continue;
- }
- if (!forced[key]) continue;
- [seen addObject:key];
- [out addObject:attributeEntry(key, forced[key])];
- }
- for (NSString *key in forced) {
- if (![seen containsObject:key]) [out addObject:attributeEntry(key, forced[key])];
- }
- return SGPBSerialize(out);
-}
-
-#pragma mark - remote config
-
-typedef NS_ENUM(NSInteger, SGRuleKind) { SGRuleRemove, SGRuleSet, SGRuleForce, SGRuleEnum };
-// A NULL scope or name matches any. Set changes a value that is there, Force adds it when it is not.
-typedef struct { const char *scope, *name; SGRuleKind kind; BOOL on; const char *text; } SGRule;
-
-static const SGRule rules[] = {
- // The ios-feature-settings flags only draw the rows; the player core gates each on its own scope.
- {"ios-feature-settings", "crossfade_enabled", SGRuleForce, YES, NULL},
- {"ios-feature-settings", "automix_enabled", SGRuleForce, YES, NULL},
- {"core-playback-setup", "crossfade_enabled", SGRuleForce, YES, NULL},
- {"core-automix", "automix_enabled", SGRuleForce, YES, NULL},
- {"ios-feature-settings", "use_playback_settings_crossfade", SGRuleForce, NO, NULL},
- {"ios-feature-settings", "use_playback_settings_gapless", SGRuleForce, NO, NULL},
- {NULL, "enable_common_capping", SGRuleRemove, NO, NULL},
- {NULL, "enable_pns_common_capping", SGRuleRemove, NO, NULL},
- {NULL, "enable_pick_and_shuffle_common_capping", SGRuleRemove, NO, NULL},
- {NULL, "enable_pick_and_shuffle_dynamic_cap", SGRuleRemove, NO, NULL},
- {NULL, "pick_and_shuffle_timecap", SGRuleRemove, NO, NULL},
- {"ios-feature-queue", NULL, SGRuleRemove, NO, NULL},
- {NULL, "enable_free_on_demand_experiment", SGRuleRemove, NO, NULL},
- {NULL, "enable_free_on_demand_context_menu_experiment", SGRuleRemove, NO, NULL},
- {NULL, "enable_mft_plus_queue", SGRuleRemove, NO, NULL},
- {NULL, "enable_mft_plus_extended_queue", SGRuleRemove, NO, NULL},
- {NULL, "enable_playback_timeout_service", SGRuleSet, NO, NULL},
- {NULL, "enable_playback_timeout_error_ui", SGRuleSet, NO, NULL},
- {NULL, "playback_timeout_action", SGRuleEnum, NO, "Nothing"},
- {NULL, "is_remove_from_queue_enabled_for_mft_plus", SGRuleRemove, NO, NULL},
- {NULL, "is_reordering_for_mft_plus_allowed", SGRuleRemove, NO, NULL},
- {NULL, "ads", SGRuleSet, NO, NULL},
- {NULL, "ad_metadata", SGRuleRemove, NO, NULL},
- {NULL, "ad_slots", SGRuleRemove, NO, NULL},
- {NULL, "enable_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_audio_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_display_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_video_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_premium_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_upsell", SGRuleSet, NO, NULL},
- {NULL, "show_upsell", SGRuleSet, NO, NULL},
- {NULL, "show_premium_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_campaigns", SGRuleSet, NO, NULL},
- {NULL, "enable_promotions", SGRuleSet, NO, NULL},
- {NULL, "enable_search_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_search_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_search_banner_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_search_banner_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_search_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_search_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_search_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_home_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_home_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_home_banner_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_home_banner_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_home_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_home_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_home_upsell", SGRuleSet, NO, NULL},
- {"ios-feature-shuffletoggleupsell", "is_enabled_pt2", SGRuleForce, NO, NULL},
- {"ios-feature-shuffletoggleupsell", "linear_upsell_new_style_experiment_enabled", SGRuleForce, NO, NULL},
- {"ios-feature-shuffletoggleupsell", "play_modes_upsell_new_style_experiment_enabled", SGRuleForce, NO, NULL},
- {"ios-jam-freeusershuffleupsellsheetpage-impl", "free_user_shuffle_upsell_sheet_enabled", SGRuleForce, NO, NULL},
- {"ios-jam-freeuserskipupsellpage-impl", "free_user_skip_upsell_sheet_enabled", SGRuleForce, NO, NULL},
- {"ios-jam-freehostedjamsupsell-impl", "free_hosted_jams_upsell_enabled", SGRuleForce, NO, NULL},
- {"ios-reinventfree-contextualupsellpremiumpromo-impl", "is_promo_cta_enabled", SGRuleForce, NO, NULL},
- {"ios-reinventfree-contextualupsellpremiumpromo-impl", "show_time_cap_upsell_with_premium_badge", SGRuleForce, NO, NULL},
- {"ios-reinventfree-controllerui-impl", "enable_video_time_cap_upsell", SGRuleForce, NO, NULL},
- {"ios-reinventfree-controllerui-impl", "enable_video_time_cap_upsell_on_search", SGRuleForce, NO, NULL},
- {"ios-reinventfree-timecappivot-impl", "music_video_upsell_enabled", SGRuleForce, NO, NULL},
- {"ios-settings-mediaqualitypageplugin-impl", "is_gbb_upsell_enabled", SGRuleForce, NO, NULL},
- {"ios-settings-mediaqualitypageplugin-impl", "should_show_pigeon_upsell", SGRuleForce, NO, NULL},
- {"ios-system-listeningparties", "preview_ended_upsell_enabled", SGRuleForce, NO, NULL},
- {NULL, "enable_now_playing_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_now_playing_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_now_playing_banner_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_now_playing_banner_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_now_playing_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_now_playing_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_now_playing_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_artist_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_artist_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_artist_banner_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_artist_banner_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_artist_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_artist_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_artist_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_playlist_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_playlist_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_playlist_banner_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_playlist_banner_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_playlist_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_playlist_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_playlist_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_album_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_album_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_album_banner_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_album_banner_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_album_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_album_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_album_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_library_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_library_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_library_banner_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_library_banner_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_library_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_library_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_library_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_audiobook_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_audiobook_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_audiobook_banner_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_audiobook_banner_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_audiobook_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_audiobook_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_audiobook_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_podcast_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_podcast_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_podcast_banner_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_podcast_banner_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_podcast_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_podcast_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_podcast_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_content", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_playlists", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_sessions", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_stories", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_videos", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_artist", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_artists", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_album", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_albums", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_track", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_tracks", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_show", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_shows", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_episode", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_episodes", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_audiobook", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_audiobooks", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_podcast", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_podcasts", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_search", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_search_results", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_search_banner", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_search_banners", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_home", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_home_banner", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_home_banners", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_now_playing", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_now_playing_banner", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_now_playing_banners", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_artist_banner", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_artist_banners", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_playlist_banner", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_playlist_banners", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_album_banner", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_album_banners", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_library_banner", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_library_banners", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_audiobook_banner", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_audiobook_banners", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_podcast_banner", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_podcast_banners", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_search_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_search_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_home_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_home_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_now_playing_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_now_playing_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_artist_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_artist_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_playlist_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_playlist_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_album_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_album_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_library_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_library_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_audiobook_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_audiobook_sponsored_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_podcast_sponsored_ad", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_podcast_sponsored_ads", SGRuleSet, NO, NULL},
- {"ios-ad-on-app-open", NULL, SGRuleRemove, NO, NULL},
- {"ios-feature-adonappopen", NULL, SGRuleRemove, NO, NULL},
- {"ios-feature-adonappopen", "enabled", SGRuleSet, NO, NULL},
- {"ios-feature-adonappopen", "background_refresh_frequency_seconds", SGRuleSet, NO, NULL},
- {NULL, "is_ad_on_app_open_enabled", SGRuleSet, NO, NULL},
- {NULL, "ad_on_app_open_enabled", SGRuleSet, NO, NULL},
- {NULL, "adonappopen_enabled", SGRuleSet, NO, NULL},
- {"marquee", NULL, SGRuleRemove, NO, NULL},
- {"ios-feature-marquee", NULL, SGRuleRemove, NO, NULL},
- {"leavebehindadsbase", NULL, SGRuleRemove, NO, NULL},
- {"ios-feature-leavebehindadsbase", NULL, SGRuleRemove, NO, NULL},
- {"ios-nowplaying-scroll-impl", "unified_leavebehind_npv_scroll_music_enabled", SGRuleForce, NO, NULL},
- {"ios-nowplaying-scroll-impl", "unified_leavebehind_npv_scroll_podcast_enabled", SGRuleForce, NO, NULL},
- {"ios-feature-embeddedplaylist", "use_unified_leavebehind_fetch", SGRuleForce, NO, NULL},
- {"ios-adsnowplaying-embeddednpv-impl", "foreground_enabled", SGRuleForce, NO, NULL},
- {"ios-adsnowplaying-embeddednpv-impl", "music_track_change_enabled", SGRuleForce, NO, NULL},
- {"ios-adsnowplaying-embeddednpv-impl", "enable_ads_on_podcast", SGRuleForce, NO, NULL},
- {"ios-feature-instreamads", NULL, SGRuleRemove, NO, NULL},
- {"ios-adsembedded-embeddedctaelements-impl", NULL, SGRuleRemove, NO, NULL},
- {"ios-adsnowplaying-embeddednpv-impl", NULL, SGRuleRemove, NO, NULL},
- {"ios-adsplatform-elementimpl", NULL, SGRuleRemove, NO, NULL},
- {"ios-system-adssponsoredcontext", NULL, SGRuleRemove, NO, NULL},
- {"ios-feature-adsbase", "enable_ads_connect_state_observer", SGRuleSet, NO, NULL},
- {"ios-feature-adsbase", "enable_minimal_preroll_management", SGRuleSet, NO, NULL},
- {"ios-feature-adsbase", "enable_swift_ads_base_movement_logger", SGRuleSet, NO, NULL},
- {"ios-feature-adsswift", NULL, SGRuleRemove, NO, NULL},
- {"ios-feature-adsnowplayingui", "embedded_npv_video_show_with_canvas", SGRuleForce, NO, NULL},
- {"ios-feature-adssponsoredcontext", "sponsored_context_mismatch_aderror_enabled", SGRuleSet, NO, NULL},
- {"ios-feature-adssponsoredcontext", "sponsored_playlist_v2_enabled", SGRuleSet, NO, NULL},
- {"ios-feature-adssponsoredcontextnpbattachment", "sponsored_npb_slot_fetch_enabled", SGRuleSet, NO, NULL},
- {"ios-feature-adsidentitytracking", NULL, SGRuleRemove, NO, NULL},
- {NULL, "enable_popups", SGRuleSet, NO, NULL},
- {NULL, "enable_leave_behind_ads_card_element", SGRuleSet, NO, NULL},
- {NULL, "music_npv_leavebehinds_enabled", SGRuleSet, NO, NULL},
- {NULL, "enable_ads_on_podcast", SGRuleSet, NO, NULL},
- {NULL, "enable_display_element", SGRuleSet, NO, NULL},
- {NULL, "enable_video_element", SGRuleSet, NO, NULL},
- {NULL, "is_promo_cta_enabled", SGRuleSet, NO, NULL},
- {NULL, "show_time_cap_upsell_with_premium_badge", SGRuleSet, NO, NULL},
- {NULL, "enable_video_time_cap_upsell", SGRuleSet, NO, NULL},
- {NULL, "enable_video_time_cap_upsell_on_search", SGRuleSet, NO, NULL},
- {NULL, "music_video_upsell_enabled", SGRuleSet, NO, NULL},
- {NULL, "is_gbb_upsell_enabled", SGRuleSet, NO, NULL},
- {NULL, "should_show_pigeon_upsell", SGRuleSet, NO, NULL},
- {NULL, "disable_suggested_tracks_upsell", SGRuleSet, YES, NULL},
- {NULL, "is_enabled_pt2", SGRuleSet, NO, NULL},
- {NULL, "show_skip_button_during_skippable_ads", SGRuleSet, YES, NULL},
- {NULL, "sponsored_playlist_v2_header_dismissible", SGRuleSet, YES, NULL},
- {NULL, "use_mock_sponsorship_endpoint", SGRuleSet, NO, NULL},
- {NULL, "enable_popup", SGRuleSet, NO, NULL},
- {NULL, "show_popups", SGRuleSet, NO, NULL},
- {NULL, "show_popup", SGRuleSet, NO, NULL},
- {NULL, "enable_interstitials", SGRuleSet, NO, NULL},
- {NULL, "enable_interstitial", SGRuleSet, NO, NULL},
- {NULL, "enable_overlays", SGRuleSet, NO, NULL},
- {NULL, "enable_overlay", SGRuleSet, NO, NULL},
- {NULL, "enable_promotions_on_home", SGRuleSet, NO, NULL},
- {NULL, "enable_promotions_on_search", SGRuleSet, NO, NULL},
- {NULL, "enable_search_page_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_home_page_ads", SGRuleSet, NO, NULL},
- {NULL, "enable_billboard", SGRuleSet, NO, NULL},
- {NULL, "enable_billboards", SGRuleSet, NO, NULL},
- {NULL, "enable_audio_ads_player", SGRuleSet, NO, NULL},
- {NULL, "enable_display_ads_player", SGRuleSet, NO, NULL},
- {NULL, "enable_video_ads_player", SGRuleSet, NO, NULL},
- {NULL, "enable_audio_ads_player_v2", SGRuleSet, NO, NULL},
- {NULL, "enable_display_ads_player_v2", SGRuleSet, NO, NULL},
- {NULL, "enable_video_ads_player_v2", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_search_results_v2", SGRuleSet, NO, NULL},
- {NULL, "enable_sponsored_home_results_v2", SGRuleSet, NO, NULL},
- {"ios-feature-search", "prompted_playlist_merchandizing_enabled", SGRuleSet, NO, NULL},
- {NULL, "should_nova_scroll_use_scrollsita", SGRuleRemove, NO, NULL},
- {"ios-sociallistening-configuration-impl", "premium_gated_start_jam_buttons_enabled", SGRuleForce, NO, NULL},
-};
-static const size_t ruleCount = sizeof(rules) / sizeof(rules[0]);
-
-static BOOL ruleMatches(const SGRule *rule, NSString *scope, NSString *name) {
- if (rule->scope && ![scope isEqualToString:@(rule->scope)]) return NO;
- return !rule->name || [name isEqualToString:@(rule->name)];
-}
-
-// A false BoolValue is an empty message, as protobuf writes it.
-static NSData *boolValue(BOOL on) {
- return on ? SGPBSerialize(@[SGPBVarint(1, 1)]) : [NSData data];
-}
-
-static void setValue(NSMutableArray<SGPBField *> *value, SGPBField *replacement) {
- [value filterUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(SGPBField *field, NSDictionary *bindings) {
- return field.number < 3 || field.number > 5;
- }]];
- [value addObject:replacement];
-}
-
-static NSData *patchConfiguration(NSData *configuration) {
- NSMutableArray<SGPBField *> *fields = SGPBParse(configuration);
- if (!fields) return nil;
- NSMutableArray<SGPBField *> *out = [NSMutableArray array];
- NSMutableSet<NSString *> *present = [NSMutableSet set];
- for (SGPBField *field in fields) {
- NSMutableArray<SGPBField *> *value = field.number == 3 && field.wire == 2 ? SGPBParse(field.payload) : nil;
- SGPBField *identifier = SGPBFirst(value, 1);
- NSArray<SGPBField *> *parts = identifier ? SGPBParse(identifier.payload) : nil;
- if (!parts) {
- [out addObject:field];
- continue;
- }
- NSString *scope = SGPBText(SGPBFirst(parts, 1)) ?: @"", *name = SGPBText(SGPBFirst(parts, 2)) ?: @"";
- BOOL removed = NO;
- for (size_t i = 0; i < ruleCount && !removed; i++) {
- if (!ruleMatches(&rules[i], scope, name)) continue;
- switch (rules[i].kind) {
- case SGRuleRemove: removed = YES; break;
- case SGRuleSet:
- // Set changes a boolean that is there; a value of another kind (a count of seconds, say)
- // under the same name is left as the server sent it rather than turned into a false.
- if (SGPBFirst(value, 3)) setValue(value, SGPBBytes(3, boolValue(rules[i].on)));
- break;
- case SGRuleForce: setValue(value, SGPBBytes(3, boolValue(rules[i].on))); break;
- case SGRuleEnum: setValue(value, SGPBBytes(5, SGPBSerialize(@[SGPBString(1, @(rules[i].text))]))); break;
- }
- }
- if (removed) continue;
- [present addObject:[NSString stringWithFormat:@"%@.%@", scope, name]];
- field.payload = SGPBSerialize(value);
- [out addObject:field];
- }
- for (size_t i = 0; i < ruleCount; i++) {
- if (rules[i].kind != SGRuleForce || !rules[i].scope || !rules[i].name) continue;
- if ([present containsObject:[NSString stringWithFormat:@"%s.%s", rules[i].scope, rules[i].name]]) continue;
- NSData *identifier = SGPBSerialize(@[SGPBString(1, @(rules[i].scope)), SGPBString(2, @(rules[i].name))]);
- [out addObject:SGPBBytes(3, SGPBSerialize(@[SGPBBytes(1, identifier), SGPBBytes(3, boolValue(rules[i].on))]))];
- }
- return SGPBSerialize(out);
-}
-
-#pragma mark - the response
-
-static NSData *patchUcs(NSData *ucs) {
- NSMutableArray<SGPBField *> *fields = SGPBParse(ucs);
- if (!fields) return nil;
- SGPBField *resolve = SGPBFirst(fields, 1);
- if (resolve.wire == 2) {
- NSData *edited = SGPBEdit(resolve.payload, @[@1], ^NSData *(NSData *configuration) {
- return patchConfiguration(configuration);
- });
- if (edited) resolve.payload = edited;
- }
- SGPBField *attributes = SGPBFirst(fields, 3);
- if (!attributes) [fields addObject:(attributes = SGPBBytes(3, nil))];
- if (attributes.wire == 2) attributes.payload = patchAttributes(attributes.payload) ?: attributes.payload;
- return SGPBSerialize(fields);
-}
-
-NSData *SGPatchCustomize(NSData *body) {
- return SGPBEdit(body, @[@1], ^NSData *(NSData *ucs) { return patchUcs(ucs); });
-}
-
-NSData *SGPatchBootstrap(NSData *body) {
- return SGPBEdit(body, @[@2, @1, @1, @1], ^NSData *(NSData *ucs) { return patchUcs(ucs); });
-}
diff --git a/tweak/Sources/Shared/Flags/Flags.x b/tweak/Sources/Shared/Flags/Flags.x
index dd0ae9c9..065514d5 100644
--- a/tweak/Sources/Shared/Flags/Flags.x
+++ b/tweak/Sources/Shared/Flags/Flags.x
@@ -1,7 +1,7 @@
// Spotify reads every remote-config flag once at startup through the configuration provider,
// keyed "component.property". The value handed back is Core/SGFlagForce.h's: what the redesign forces
// (Redesigned/Kit/SGRedesign.h), which comes before an override so one left from Spotify's own screens
-// cannot pull a redesigned one apart, then an override from the Flags page, then what the ad blocking
+// cannot pull a redesigned one apart, then an override from the Flags page, then what the Search switches
// and the lyrics sources force.
#import "Core/SGCore.h"
#import "Flags.h"
diff --git a/tweak/Sources/Shared/Lyrics/KaraokeSource.x b/tweak/Sources/Shared/Lyrics/KaraokeSource.x
index f8e99939..1a7f67d5 100644
--- a/tweak/Sources/Shared/Lyrics/KaraokeSource.x
+++ b/tweak/Sources/Shared/Lyrics/KaraokeSource.x
@@ -1,5 +1,5 @@
// Where the karaoke page gets its lines and its clock. The color-lyrics body is copied as it passes
-// the same URLSession delegates AdBlock/AdNetwork.x reads, untouched, and kept per track, since the
+// Spotify's URLSession delegates, untouched, and kept per track, since the
// page may open long after the request finished. The clock is SPTEsperantoPlayer's state, asked for on
// every frame: the player is caught the first time the app asks it, and its position runs on by itself.
// With a source of the mod's on, the color-lyrics body is Shared/LyricsSources' to answer and it
diff --git a/tweak/Sources/Shared/Lyrics/KaraokeTiming.m b/tweak/Sources/Shared/Lyrics/KaraokeTiming.m
index 25dbde4e..781b3cda 100644
--- a/tweak/Sources/Shared/Lyrics/KaraokeTiming.m
+++ b/tweak/Sources/Shared/Lyrics/KaraokeTiming.m
@@ -1,5 +1,5 @@
#import "Lyrics.h"
-#import "Shared/AdBlock/Protobuf.h"
+#import "Shared/Lyrics/Protobuf.h"
@implementation SGKaraokeWord
@end
diff --git a/tweak/Sources/Shared/AdBlock/Protobuf.h b/tweak/Sources/Shared/Lyrics/Protobuf.h
similarity index 92%
rename from tweak/Sources/Shared/AdBlock/Protobuf.h
rename to tweak/Sources/Shared/Lyrics/Protobuf.h
index 9dbda88c..e814f591 100644
--- a/tweak/Sources/Shared/AdBlock/Protobuf.h
+++ b/tweak/Sources/Shared/Lyrics/Protobuf.h
@@ -1,5 +1,5 @@
// The protobuf wire format, just enough to walk into a message, change a few fields and write it
-// back with everything else untouched. Premium.m and Feeds.m read Spotify's responses through it.
+// back with everything else untouched. The lyrics read Spotify's replies through it.
#import <Foundation/Foundation.h>
// A field as it sits on the wire: a varint carries its value, everything else its raw payload.
diff --git a/tweak/Sources/Shared/AdBlock/Protobuf.m b/tweak/Sources/Shared/Lyrics/Protobuf.m
similarity index 100%
rename from tweak/Sources/Shared/AdBlock/Protobuf.m
rename to tweak/Sources/Shared/Lyrics/Protobuf.m
diff --git a/tweak/Sources/Shared/LyricsSources/LyricsHook.x b/tweak/Sources/Shared/LyricsSources/LyricsHook.x
index 9d42a5f8..c7724990 100644
--- a/tweak/Sources/Shared/LyricsSources/LyricsHook.x
+++ b/tweak/Sources/Shared/LyricsSources/LyricsHook.x
@@ -31,7 +31,7 @@
// for the lyrics as it would for any track, and the reply is answered as above.
#import "Core/SGCore.h"
#import "LyricsSources.h"
-#import "Shared/AdBlock/Protobuf.h"
+#import "Shared/Lyrics/Protobuf.h"
#import "Headers/SPTPlayer.h"
// Blinding Lights, The Weeknd: lyrics in every market Spotify serves them in.
diff --git a/tweak/Sources/Shared/Privacy/Clutter.m b/tweak/Sources/Shared/Privacy/Clutter.m
new file mode 100644
index 00000000..663ae920
--- /dev/null
+++ b/tweak/Sources/Shared/Privacy/Clutter.m
@@ -0,0 +1,22 @@
+#import "Core/SGCore.h"
+#import "Privacy.h"
+
+static NSString *const socialProofFlags[] = {
+ @"ios-feature-search.social_proof_playlist_enabled",
+ @"ios-feature-search.social_proof_plays_in_search_enabled",
+};
+
+static BOOL forcedOff(NSString *key) {
+ if (SGHidden(SGKeyHideSearchVideos) && [key isEqualToString:@"ios-feature-search.video_carousel_section_enabled"]) return YES;
+ if (!SGHidden(SGKeyHideSocialProof)) return NO;
+ for (size_t i = 0; i < sizeof(socialProofFlags) / sizeof(socialProofFlags[0]); i++) {
+ if ([key isEqualToString:socialProofFlags[i]]) return YES;
+ }
+ return NO;
+}
+
+// After an override from the All flags page, and locking the rows that would turn the same flag off.
+__attribute__((constructor)) static void registerForcer(void) {
+ SGFlagForcer off = ^id(NSString *key) { return forcedOff(key) ? @NO : nil; };
+ SGRegisterFlagForcer(NO, off, off);
+}
diff --git a/tweak/Sources/Shared/Privacy/Privacy.h b/tweak/Sources/Shared/Privacy/Privacy.h
index f176a3af..d16c5934 100644
--- a/tweak/Sources/Shared/Privacy/Privacy.h
+++ b/tweak/Sources/Shared/Privacy/Privacy.h
@@ -3,6 +3,9 @@
#import <UIKit/UIKit.h>
#define SGKeyBlockTelemetry @"spotifyglass.blockTelemetry"
+// Search clutter (Clutter.m); on forces its flags off.
+#define SGKeyHideSearchVideos @"spotifyglass.adblock.searchVideos"
+#define SGKeyHideSocialProof @"spotifyglass.adblock.socialProof"
// The destinations it knows in the order it lists them, and how many requests to one of them it
// has answered instead of letting out (nil label for all of them).
@@ -10,7 +13,5 @@ NSArray<NSString *> *SGBlockedLabels(void);
NSUInteger SGBlockedCount(NSString *label);
void SGResetBlocked(void);
-@class SGModSection;
-// The telemetry switch and what it has stopped, on the Premium, ads & privacy page.
-SGModSection *SGPrivacySection(void);
-SGModSection *SGPrivacyCountersSection(void);
+// The Privacy & clutter page: telemetry, the Search switches, the tips, what telemetry blocking stopped.
+UIViewController *SGPrivacySettingsPage(void);
diff --git a/tweak/Sources/Shared/Privacy/PrivacySettings.m b/tweak/Sources/Shared/Privacy/PrivacySettings.m
index 599eebfa..55d96b0a 100644
--- a/tweak/Sources/Shared/Privacy/PrivacySettings.m
+++ b/tweak/Sources/Shared/Privacy/PrivacySettings.m
@@ -1,13 +1,28 @@
#import "Settings/SGModPage.h"
#import "Privacy.h"
-SGModSection *SGPrivacySection(void) {
- return SGSection(@"Privacy", @[
- SGWithSymbol(SGSwitchRow(@"Block telemetry", @"Spotify's own events still go out, since Recents is built from them", SGKeyBlockTelemetry), @"antenna.radiowaves.left.and.right.slash"),
- ]);
+// Every switch here forces a flag Spotify ships on to off, so the titles name the hiding: on hides
+// the thing, off is Spotify's own value.
+static UIViewController *tipsPage(void) {
+ return [[SGModPage alloc] initWithTitle:@"Tips" intro:SGRestartNote sections:@[
+ SGSection(@"Reduce interventions", @[
+ SGFlagRow(@"Reduce interventions", @"ios-messaging-reduceinterventions-impl.enabled"),
+ ]),
+ SGSection(@"Tooltips", @[
+ SGKillRow(@"Hide the smart shuffle helper", @"ios-messaging-reduceinterventions-impl.enable_message_smart_shuffle_helper_tooltip"),
+ SGKillRow(@"Hide the data saver tip", @"ios-feature-nowplayingbar.data_saver_tooltip"),
+ SGKillRow(@"Hide the AI playlist creation tip", @"ios-messaging-reduceinterventions-impl.enable_message_your_library_ai_playlist_creation_tooltip"),
+ SGKillRow(@"Hide the watch feed explorer tip", @"ios-messaging-reduceinterventions-impl.enable_message_watch_feed_entity_explorer_tooltip"),
+ SGKillRow(@"Hide the account switching tip", @"ios-messaging-reduceinterventions-impl.enable_message_account_switching_tooltip"),
+ SGKillRow(@"Hide the concert notifications tip", @"ios-messaging-reduceinterventions-impl.enable_message_live_events_concert_notifications_tooltip"),
+ SGKillRow(@"Hide the live event tip", @"ios-messaging-reduceinterventions-impl.enable_message_live_events_event_entity_safe_tooltip"),
+ SGKillRow(@"Hide the live event venue tip", @"ios-messaging-reduceinterventions-impl.enable_message_live_events_event_entity_venuename_header_tooltip"),
+ SGKillRow(@"Hide the Puffin nudge", @"ios-messaging-reduceinterventions-impl.enable_message_puffin_nudge_end_optimization"),
+ ]),
+ ] footer:nil];
}
-SGModSection *SGPrivacyCountersSection(void) {
+static SGModSection *countersSection(void) {
NSMutableArray<SGModRow *> *counts = [NSMutableArray array];
for (NSString *label in SGBlockedLabels()) {
[counts addObject:SGStatRow(label, ^NSString *{
@@ -20,3 +35,18 @@ SGModSection *SGPrivacyCountersSection(void) {
[counts addObject:SGActionRow(@"Reset the telemetry counters", nil, ^{ SGResetBlocked(); })];
return SGSection(@"Telemetry blocked so far", counts);
}
+
+// The switches first and what they have stopped last, so the counters bury no setting.
+UIViewController *SGPrivacySettingsPage(void) {
+ return [[SGModPage alloc] initWithTitle:@"Privacy & clutter" intro:SGRestartNote sections:@[
+ SGSection(@"Privacy", @[
+ SGWithSymbol(SGSwitchRow(@"Block telemetry", @"Spotify's own events still go out, since Recents is built from them", SGKeyBlockTelemetry), @"antenna.radiowaves.left.and.right.slash"),
+ ]),
+ SGSection(@"Clutter", @[
+ SGWithSymbol(SGOptionRow(@"Hide the video carousel in Search", nil, SGKeyHideSearchVideos), @"play.rectangle.on.rectangle"),
+ SGWithSymbol(SGOptionRow(@"Hide social proof in Search", nil, SGKeyHideSocialProof), @"person.2"),
+ SGWithSymbol(SGPageRow(@"Tips", ^UIViewController *{ return tipsPage(); }), @"lightbulb"),
+ ]),
+ countersSection(),
+ ] footer:nil];
+}