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

fix: Hide ads no longer blocks player routes whose names contain "ad"

My-Name-Is-Jeff524d8454f0e6
diff --git a/tweak/Sources/Shared/AdBlock/AdNetwork.x b/tweak/Sources/Shared/AdBlock/AdNetwork.x
index 02e38c6d..121aecf7 100644
--- a/tweak/Sources/Shared/AdBlock/AdNetwork.x
+++ b/tweak/Sources/Shared/AdBlock/AdNetwork.x
@@ -51,11 +51,27 @@ static NSString *const adPaths[] = {
@"/upgrade-component/", @"/marketing/", @"/home-ads/", @"/search-ads/",
};
+// Esperanto service names use dot/underscore-separated identifiers as well as URL
+// path segments. A word-boundary regex alone would not split underscores. Match
+// whole ad/slot tokens after /esperanto/, never the "ad" inside load or metadata.
+static BOOL isEsperantoAd(NSString *path) {
+ NSRange marker = [path rangeOfString:@"/esperanto/"];
+ if (marker.location == NSNotFound) return NO;
+ static NSRegularExpression *tokens;
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{
+ tokens = [NSRegularExpression regularExpressionWithPattern:@"(?:^|[/._-])(?:ads?|slots?)(?=$|[/._-])"
+ options:0 error:NULL];
+ });
+ NSString *route = [path substringFromIndex:NSMaxRange(marker)];
+ return [tokens firstMatchInString:route options:0 range:NSMakeRange(0, route.length)] != nil;
+}
+
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;
+ if (isEsperantoAd(path)) 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];