Changes the App Store's "GET" text to "Free"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.3KB

  1. // GetFree - Changes the App Store's "GET" text to "Free"
  2. // By mac-user669
  3. // Based off Stonks by Skitty
  4. static BOOL enabled = YES;
  5. NSString *GetToFree(NSString *origString) {
  6. NSString *newString = [origString stringByReplacingOccurrencesOfString:@"GET" withString:@"Free"];
  7. return newString;
  8. }
  9. NSAttributedString *attributedGetToFree(NSAttributedString *origString) {
  10. NSMutableAttributedString *newString = [origString mutableCopy];
  11. while ([newString.mutableString containsString:@"GET"]) {
  12. NSRange range = [newString.mutableString rangeOfString:@"GET"];
  13. NSMutableAttributedString *replaceString = [[NSMutableAttributedString alloc] initWithString:@"Free"];
  14. [newString enumerateAttributesInRange:range options:0 usingBlock:^(NSDictionary<NSAttributedStringKey, id> *attrs, NSRange range, BOOL *stop) {
  15. [replaceString addAttributes:attrs range:NSMakeRange(0, replaceString.length)];
  16. }];
  17. [newString replaceCharactersInRange:range withAttributedString:replaceString];
  18. }
  19. return [newString copy];
  20. }
  21. // Actual hook
  22. %hook UILabel
  23. - (void)setText:(NSString *)text {
  24. if (enabled) {
  25. text = GetToFree(text);
  26. }
  27. %orig(text);
  28. }
  29. - (void)setAttributedText:(NSAttributedString *)attributedText {
  30. if (enabled) {
  31. attributedText = attributedGetToFree(attributedText);
  32. }
  33. %orig(attributedText);
  34. }
  35. %end