forked from dayanch96/YTLite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
657 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
ifeq ($(ROOTLESS),1) | ||
THEOS_PACKAGE_SCHEME=rootless | ||
endif | ||
|
||
DEBUG=0 | ||
FINALPACKAGE=1 | ||
ARCHS = arm64 | ||
PACKAGE_VERSION = 1.0 | ||
TARGET := iphone:clang:latest:11.0 | ||
|
||
include $(THEOS)/makefiles/common.mk | ||
|
||
TWEAK_NAME = YTLite | ||
$(TWEAK_NAME)_FRAMEWORKS = UIKit Foundation | ||
$(TWEAK_NAME)_CFLAGS = -fobjc-arc -DTWEAK_VERSION=$(PACKAGE_VERSION) | ||
$(TWEAK_NAME)_FILES = YTLite.x Settings.x | ||
|
||
include $(THEOS_MAKE_PATH)/tweak.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
#import "YTLite.h" | ||
|
||
@interface YTSettingsSectionItemManager (YTLite) | ||
- (void)updateYTLiteSectionWithEntry:(id)entry; | ||
@end | ||
|
||
static const NSInteger YTLiteSection = 789; | ||
|
||
NSBundle *YTLiteBundle() { | ||
static NSBundle *bundle = nil; | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
NSString *tweakBundlePath = [[NSBundle mainBundle] pathForResource:@"YTLite" ofType:@"bundle"]; | ||
if (tweakBundlePath) | ||
bundle = [NSBundle bundleWithPath:tweakBundlePath]; | ||
else | ||
bundle = [NSBundle bundleWithPath:ROOT_PATH_NS("/Library/Application Support/YTLite.bundle")]; | ||
}); | ||
return bundle; | ||
} | ||
|
||
// Settings | ||
%hook YTAppSettingsPresentationData | ||
+ (NSArray *)settingsCategoryOrder { | ||
NSArray *order = %orig; | ||
NSMutableArray *mutableOrder = [order mutableCopy]; | ||
NSUInteger insertIndex = [order indexOfObject:@(1)]; | ||
if (insertIndex != NSNotFound) | ||
[mutableOrder insertObject:@(YTLiteSection) atIndex:insertIndex + 1]; | ||
return mutableOrder; | ||
} | ||
%end | ||
|
||
%hook YTSettingsSectionController | ||
- (void)setSelectedItem:(NSUInteger)selectedItem { | ||
if (selectedItem != NSNotFound) %orig; | ||
} | ||
%end | ||
|
||
%hook YTSettingsSectionItemManager | ||
%new | ||
- (void)updatePrefsForKey:(NSString *)key enabled:(BOOL)enabled { | ||
NSString *prefsPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"YTLite.plist"]; | ||
NSMutableDictionary *prefs = [NSMutableDictionary dictionaryWithContentsOfFile:prefsPath]; | ||
|
||
if (!prefs) prefs = [NSMutableDictionary dictionary]; | ||
|
||
[prefs setObject:@(enabled) forKey:key]; | ||
[prefs writeToFile:prefsPath atomically:NO]; | ||
|
||
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.dvntm.ytlite.prefschanged"), NULL, NULL, YES); | ||
} | ||
|
||
%new(v@:@) | ||
- (void)updateYTLiteSectionWithEntry:(id)entry { | ||
NSMutableArray *sectionItems = [NSMutableArray array]; | ||
Class YTSettingsSectionItemClass = %c(YTSettingsSectionItem); | ||
YTSettingsViewController *settingsViewController = [self valueForKey:@"_settingsViewControllerDelegate"]; | ||
|
||
YTSettingsSectionItem *general = [YTSettingsSectionItemClass itemWithTitle:LOC(@"General") | ||
accessibilityIdentifier:nil | ||
detailTextBlock:^NSString *() { | ||
return @"‣"; | ||
} | ||
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { | ||
NSArray <YTSettingsSectionItem *> *rows = @[ | ||
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"RemoveAds") | ||
titleDescription:LOC(@"RemoveAdsDesc") | ||
accessibilityIdentifier:nil | ||
switchOn:kNoAds | ||
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { | ||
[self updatePrefsForKey:@"noAds" enabled:enabled]; | ||
return YES; | ||
} | ||
settingItemId:0], | ||
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"BackgroundPlayback") | ||
titleDescription:LOC(@"BackgroundPlaybackDesc") | ||
accessibilityIdentifier:nil | ||
switchOn:kBackgroundPlayback | ||
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { | ||
[self updatePrefsForKey:@"backgroundPlayback" enabled:enabled]; | ||
return YES; | ||
} | ||
settingItemId:0] | ||
]; | ||
|
||
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"General") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]]; | ||
[settingsViewController pushViewController:picker]; | ||
return YES; | ||
}]; | ||
[sectionItems addObject:general]; | ||
|
||
YTSettingsSectionItem *navbar = [YTSettingsSectionItemClass itemWithTitle:LOC(@"Navbar") | ||
accessibilityIdentifier:nil | ||
detailTextBlock:^NSString *() { | ||
return @"‣"; | ||
} | ||
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { | ||
NSArray <YTSettingsSectionItem *> *rows = @[ | ||
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"RemoveCast") | ||
titleDescription:LOC(@"RemoveCastDesc") | ||
accessibilityIdentifier:nil | ||
switchOn:kNoCast | ||
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { | ||
[self updatePrefsForKey:@"noCast" enabled:enabled]; | ||
return YES; | ||
} | ||
settingItemId:0], | ||
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"RemoveNotifications") | ||
titleDescription:LOC(@"RemoveNotificationsDesc") | ||
accessibilityIdentifier:nil | ||
switchOn:kNoNotifsButton | ||
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { | ||
[self updatePrefsForKey:@"removeNotifsButton" enabled:enabled]; | ||
return YES; | ||
} | ||
settingItemId:0], | ||
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"RemoveSearch") | ||
titleDescription:LOC(@"RemoveSearchDesc") | ||
accessibilityIdentifier:nil | ||
switchOn:kNoSearchButton | ||
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { | ||
[self updatePrefsForKey:@"removeSearchButton" enabled:enabled]; | ||
return YES; | ||
} | ||
settingItemId:0] | ||
]; | ||
|
||
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"Navbar") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]]; | ||
[settingsViewController pushViewController:picker]; | ||
return YES; | ||
}]; | ||
[sectionItems addObject:navbar]; | ||
|
||
YTSettingsSectionItem *tabbar = [YTSettingsSectionItemClass itemWithTitle:LOC(@"Tabbar") | ||
accessibilityIdentifier:nil | ||
detailTextBlock:^NSString *() { | ||
return @"‣"; | ||
} | ||
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { | ||
NSArray <YTSettingsSectionItem *> *rows = @[ | ||
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"RemoveLabels") | ||
titleDescription:LOC(@"RemoveLabelsDesc") | ||
accessibilityIdentifier:nil | ||
switchOn:kRemoveLabels | ||
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { | ||
[self updatePrefsForKey:@"removeLabels" enabled:enabled]; | ||
return YES; | ||
} | ||
settingItemId:0], | ||
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HideShortsTab") | ||
titleDescription:LOC(@"HideShortsTabDesc") | ||
accessibilityIdentifier:nil | ||
switchOn:kRemoveShorts | ||
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { | ||
[self updatePrefsForKey:@"removeShorts" enabled:enabled]; | ||
return YES; | ||
} | ||
settingItemId:0], | ||
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HideSubscriptionsTab") | ||
titleDescription:LOC(@"HideSubscriptionsTabDesc") | ||
accessibilityIdentifier:nil | ||
switchOn:kRemoveSubscriptions | ||
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { | ||
[self updatePrefsForKey:@"removeSubscriptions" enabled:enabled]; | ||
return YES; | ||
} | ||
settingItemId:0], | ||
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HideUploadButton") | ||
titleDescription:LOC(@"HideUploadButtonDesc") | ||
accessibilityIdentifier:nil | ||
switchOn:kRemoveUploads | ||
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { | ||
[self updatePrefsForKey:@"removeUploads" enabled:enabled]; | ||
return YES; | ||
} | ||
settingItemId:0], | ||
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HideLibraryTab") | ||
titleDescription:LOC(@"HideLibraryTabDesc") | ||
accessibilityIdentifier:nil | ||
switchOn:kRemoveLibrary | ||
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { | ||
[self updatePrefsForKey:@"removeLibrary" enabled:enabled]; | ||
return YES; | ||
} | ||
settingItemId:0] | ||
]; | ||
|
||
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"Tabbar") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]]; | ||
[settingsViewController pushViewController:picker]; | ||
return YES; | ||
}]; | ||
[sectionItems addObject:tabbar]; | ||
|
||
YTSettingsSectionItem *ps = [%c(YTSettingsSectionItem) itemWithTitle:@"PoomSmart" titleDescription:@"YouTube-X, YTNoPremium, YouTubeHeaders" accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { | ||
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://github.com/PoomSmart/"]]; | ||
}]; | ||
|
||
YTSettingsSectionItem *dayanch96 = [%c(YTSettingsSectionItem) itemWithTitle:@"Dayanch96" titleDescription:LOC(@"Developer") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { | ||
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://github.com/Dayanch96/"]]; | ||
}]; | ||
|
||
YTSettingsSectionItem *version = [YTSettingsSectionItemClass itemWithTitle:LOC(@"Version") | ||
accessibilityIdentifier:nil | ||
detailTextBlock:^NSString *() { | ||
return @(OS_STRINGIFY(TWEAK_VERSION)); | ||
} | ||
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { | ||
NSArray <YTSettingsSectionItem *> *rows = @[ps, dayanch96]; | ||
|
||
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"About") pickerSectionTitle:LOC(@"Credits") rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]]; | ||
[settingsViewController pushViewController:picker]; | ||
return YES; | ||
}]; | ||
[sectionItems addObject:version]; | ||
|
||
[settingsViewController setSectionItems:sectionItems forCategory:YTLiteSection title:@"YTLite" titleDescription:nil headerHidden:NO]; | ||
} | ||
|
||
- (void)updateSectionForCategory:(NSUInteger)category withEntry:(id)entry { | ||
if (category == YTLiteSection) { | ||
[self updateYTLiteSectionWithEntry:entry]; | ||
return; | ||
} %orig; | ||
} | ||
%end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#import <UIKit/UIKit.h> | ||
#import <Foundation/Foundation.h> | ||
#import <rootless.h> | ||
#import "../YouTubeHeader/YTIPivotBarSupportedRenderers.h" | ||
#import "../YouTubeHeader/YTIPivotBarRenderer.h" | ||
#import "../YouTubeHeader/YTISectionListRenderer.h" | ||
#import "../YouTubeHeader/YTQTMButton.h" | ||
#import "../YouTubeHeader/YTSettingsViewController.h" | ||
#import "../YouTubeHeader/YTSettingsSectionItem.h" | ||
#import "../YouTubeHeader/YTSettingsSectionItemManager.h" | ||
#import "../YouTubeHeader/YTSettingsPickerViewController.h" | ||
#import "../YouTubeHeader/YTUIUtils.h" | ||
|
||
extern NSBundle *YTLiteBundle(); | ||
|
||
static inline NSString *LOC(NSString *key) { | ||
NSBundle *tweakBundle = YTLiteBundle(); | ||
return [tweakBundle localizedStringForKey:key value:nil table:nil]; | ||
} | ||
|
||
BOOL kNoAds; | ||
BOOL kBackgroundPlayback; | ||
BOOL kNoCast; | ||
BOOL kNoNotifsButton; | ||
BOOL kNoSearchButton; | ||
BOOL kRemoveLabels; | ||
BOOL kRemoveShorts; | ||
BOOL kRemoveSubscriptions; | ||
BOOL kRemoveUploads; | ||
BOOL kRemoveLibrary; | ||
|
||
@interface YTPivotBarView : UIView | ||
@end | ||
|
||
@interface YTPivotBarItemView : UIView | ||
@end | ||
|
||
@interface YTRightNavigationButtons : UIView | ||
@property (nonatomic, strong) YTQTMButton *notificationButton; | ||
@property (nonatomic, strong) YTQTMButton *searchButton; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>Filter</key> | ||
<dict> | ||
<key>Bundles</key> | ||
<array> | ||
<string>com.google.ios.youtube</string> | ||
</array> | ||
</dict> | ||
</dict> | ||
</plist> |
Oops, something went wrong.