Skip to content

Commit

Permalink
Fix apollogur.download request blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyCA committed Nov 27, 2023
1 parent e09c647 commit aa69123
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [v1.0.3] - 2023-11-26
## [v1.0.3b] - 2023-11-26
- Treat `x.com` links as Twitter links so they can be opened in Twitter app
- Fix issue with `apollogur.download` network requests not getting blocked properly (#3)

## [v1.0.2c] - 2023-11-08
- Fix Imgur multi-image uploads (first attempt usually fails but subsequent retries should succeed)
Expand All @@ -16,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## [v1.0.0] - 2023-10-13
- Initial release

[v1.0.3]: https://github.com/JeffreyCA/Apollo-ImprovedCustomApi/compare/v1.0.2c...v1.0.3
[v1.0.3b]: https://github.com/JeffreyCA/Apollo-ImprovedCustomApi/compare/v1.0.2c...v1.0.3b
[v1.0.2c]: https://github.com/JeffreyCA/Apollo-ImprovedCustomApi/compare/v1.0.1...v1.0.2c
[v1.0.1]: https://github.com/JeffreyCA/Apollo-ImprovedCustomApi/compare/v1.0.0...v1.0.1
[v1.0.0]: https://github.com/JeffreyCA/Apollo-ImprovedCustomApi/compare/v1.0.0
Expand Down
25 changes: 16 additions & 9 deletions Tweak.x
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ static OSStatus SecItemUpdate_replacement(CFDictionaryRef query, CFDictionaryRef
return ((OSStatus (*)(CFDictionaryRef, CFDictionaryRef))SecItemUpdate_orig)((__bridge CFDictionaryRef)strippedQuery, attributesToUpdate);
}

static NSArray *blockedUrls = @[
@"https://apollopushserver.xyz",
@"telemetrydeck.com",
@"https://apollogur.download/api/apollonouncement",
@"https://apollogur.download/api/easter_sale",
@"https://apollogur.download/api/html_codes",
@"https://apollogur.download/api/refund_screen_config",
@"https://apollogur.download/api/goodbye_wallpaper"
];

%hook NSURL

- (NSString *)host {
Expand Down Expand Up @@ -112,12 +122,7 @@ static NSString *imageID;
- (NSURLSessionDataTask *)dataTaskWithURL:(NSURL *)url completionHandler:(void (^)(NSData *, NSURLResponse *, NSError *))completionHandler {
imageID = [url.lastPathComponent stringByDeletingPathExtension];
// Remove unwanted messages on app startup
if ([url.absoluteString containsString:@"https://apollogur.download/api/apollonouncement"] ||
[url.absoluteString containsString:@"https://apollogur.download/api/easter_sale"] ||
[url.absoluteString containsString:@"https://apollogur.download/api/html_codes"] ||
[url.absoluteString containsString:@"https://apollogur.download/api/refund_screen_config"]) {
return nil;
} else if ([url.absoluteString containsString:@"https://apollogur.download/api/image/"]) {
if ([url.absoluteString containsString:@"https://apollogur.download/api/image/"]) {
NSString *modifiedURLString = [NSString stringWithFormat:@"https://api.imgur.com/3/image/%@.json", imageID];
NSURL *modifiedURL = [NSURL URLWithString:modifiedURLString];
// Access the modified URL to get the actual data
Expand Down Expand Up @@ -216,9 +221,11 @@ static NSString *imageID;
NSURLRequest *request = [self valueForKey:@"_originalRequest"];
NSString *requestURL = request.URL.absoluteString;

// Drop requests to analytics/apns services
if ([requestURL containsString:@"https://apollopushserver.xyz"] || [requestURL containsString:@"telemetrydeck.com"]) {
return;
// Drop blocked URLs
for (NSString *blockedUrl in blockedUrls) {
if ([requestURL containsString:blockedUrl]) {
return;
}
}

// Intercept modified "unproxied" Imgur requests and replace Authorization header with custom client ID
Expand Down
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ca.jeffrey.apollo-improvedcustomapi
Name: Apollo-ImprovedCustomApi
Version: 1.0.2c
Version: 1.0.3b
Architecture: iphoneos-arm
Description: Apollo for Reddit tweak with in-app configurable API keys
Maintainer: JeffreyCA
Expand Down

0 comments on commit aa69123

Please sign in to comment.