Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static NSString *BlurValue;
  2. BOOL PlayButtonHide;
  3. BOOL PreviousButtonHide;
  4. BOOL NextButtonHide;
  5. BOOL HeartButtonBarHide;
  6. BOOL HeartButtonViewHide;
  7. BOOL AttributionHide;
  8. BOOL ChangeBlur;
  9. BOOL RightAccessoryIndicator;
  10. BOOL LeftAccessoryIndicator;
  11. BOOL RadialGrad;
  12. BOOL CoverArt;
  13. BOOL IdleTime;
  14.  
  15. //Respring function, needed to perform a proper respring.
  16. @interface FBSystemService : NSObject
  17. +(id)sharedInstance;
  18. -(void)exitAndRelaunch:(bool)arg1;
  19. @end
  20.  
  21. static void RespringDevice() {
  22.     [[%c(FBSystemService) sharedInstance] exitAndRelaunch:YES];
  23. }
  24. //End respring
  25.  
  26. %hook SPTNowPlayingPreviousTrackButton
  27.   -(long long) icon {
  28.     if(PreviousButtonHide) {
  29.       return nil;
  30.     } else {
  31.       return %orig;
  32.     }
  33.   }
  34. %end
  35.  
  36. %hook SPTNowPlayingNextTrackButton
  37.   -(long long) icon {
  38.     if(NextButtonHide) {
  39.         return nil;
  40.       } else {
  41.         return %orig;
  42.       }
  43.     }
  44. %end
  45.  
  46. %hook SPTNowPlayingPlayButtonV2
  47.   -(void) applyIcon {
  48.     if(PlayButtonHide) {
  49.       return;
  50.     } else {
  51.       %orig;
  52.     }
  53.   }
  54. %end
  55.  
  56. %hook SPTNowPlayingBarHeartViewController
  57.   -(void) viewDidLoad {
  58.     if(HeartButtonBarHide) {
  59.       return;
  60.     }  
  61.     %orig;
  62.   }
  63. %end
  64.  
  65. %hook SPTNowPlayingFreeTierFeedbackButton
  66.   -(void) applyIcon {
  67.     if(HeartButtonViewHide) {
  68.       return;
  69.     }  
  70.     %orig;
  71.   }
  72. %end
  73.  
  74. %hook SPTCanvasViewController
  75.   -(void) setShouldShowAttribution:(bool)arg1 {
  76.     if(AttributionHide) {
  77.       arg1 = FALSE;
  78.     }
  79.     %orig(arg1);
  80.   }
  81. %end
  82.  
  83. %hook SPTImageBlurView
  84.   -(void) setBlurIntensity:(double)arg1 {
  85.     if(ChangeBlur) {
  86.       arg1 = BlurValue;
  87.     }
  88.     %orig(arg1);
  89.   }
  90. %end
  91.  
  92. %hook SPTNowPlayingHeadUnitViewV2
  93.   -(void) setRightAccessoryIndicator:(id)arg1 {
  94.     if(RightAccessoryIndicator) {
  95.       return;
  96.     }  
  97.     %orig(arg1);
  98.   }
  99. %end
  100.  
  101. %hook SPTNowPlayingHeadUnitViewV2
  102.   -(void) setLeftAccessoryIndicator:(id)arg1 {
  103.     if(RightAccessoryIndicator) {
  104.       return;
  105.     }
  106.     %orig(arg1);
  107.   }
  108. %end
  109.  
  110. %hook SPTNowPlayingShowsFormatBackgroundRadialGradientLayer
  111.   -(void) drawInContext:(CGContext*)arg1 {
  112.     if(RadialGrad) {
  113.       return;
  114.     }
  115.     %orig(arg1);
  116.   }
  117. %end
  118.  
  119. %hook SPTNowPlayingContentCell
  120.   -(void) setView:(id)arg1 visible:(BOOL)arg2 animated:(BOOL)arg3 {
  121.     if (CoverArt) {
  122.       nil;
  123.     } else {
  124.       %orig;
  125.     }
  126.   }
  127. %end
  128.  
  129. %hook SPTNowPlayingContainerIdleMonitor
  130.   -(id) initWithIdleWaitInterval:(double)arg1 view:(id)arg2 {
  131.     if(IdleTime) {
  132.       arg1 = 10;
  133.     }
  134.     return %orig;
  135.   }
  136. %end
  137.  
  138. static void loadPrefs() {
  139.   NSString *preferencesPath = @"/User/Library/Preferences/com.nicksb.lstextify.plist";
  140.   NSMutableDictionary *preferences = [[NSMutableDictionary alloc] initWithContentsOfFile:preferencesPath];
  141.   if(!preferences) {
  142.     preferences = [[NSMutableDictionary alloc] init];
  143.     PlayButtonHide = YES;
  144.     PreviousButtonHide = YES;
  145.     NextButtonHide = YES;
  146.     HeartButtonBarHide = YES;
  147.     HeartButtonViewHide = YES;
  148.     AttributionHide = YES;
  149.     ChangeBlur = YES;
  150.     RightAccessoryIndicator = YES;
  151.     LeftAccessoryIndicator = YES;
  152.     RadialGrad = YES;
  153.     CoverArt = YES;
  154.     IdleTime = YES;
  155.     BlurValue = @"0.50";
  156.   } else {
  157.     PlayButtonHide = [[preferences objectForKey:@"isEnabled"] boolValue];
  158.     PreviousButtonHide = [[preferences objectForKey:@"isEnabled2"] boolValue];
  159.     NextButtonHide = [[preferences objectForKey:@"isEnabled3"] boolValue];
  160.     HeartButtonBarHide = [[preferences objectForKey:@"isEnabled4"] boolValue];
  161.     HeartButtonViewHide = [[preferences objectForKey:@"isEnabled5"] boolValue];
  162.     AttributionHide = [[preferences objectForKey:@"isEnabled6"] boolValue];
  163.     ChangeBlur = [[preferences objectForKey:@"isEnabled7"] boolValue];
  164.     RightAccessoryIndicator = [[preferences objectForKey:@"isEnabled8"] boolValue];
  165.     LeftAccessoryIndicator = [[preferences objectForKey:@"isEnabled9"] boolValue];
  166.     RadialGrad = [[preferences objectForKey:@"isEnabled10"] boolValue];
  167.     CoverArt = [[preferences objectForKey:@"isEnabled11"] boolValue];
  168.     IdleTime = [[preferences objectForKey:@"isEnabled12"] boolValue];
  169. BlurValue = [preferences objectForKey:@"BlurValue"];
  170.    
  171.  
  172.   }
  173.   [preferences release];
  174. }
  175.  
  176. //Change this to your postNotification from your settings.
  177. static NSString *nsNotificationString = @"com.nicksb.lstextify/preferences.changed";
  178. static void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
  179.   loadPrefs();
  180. }
  181.  
  182. %ctor {
  183.   NSAutoreleasePool *pool = [NSAutoreleasePool new];
  184.   loadPrefs();
  185.   notificationCallback(NULL, NULL, NULL, NULL, NULL);
  186.   CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)nsNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce);
  187.   [pool release];
  188.  
  189. //Respring
  190.   CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)RespringDevice, CFSTR("com.nicksb.lstextify/respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement