|
|
|
#import <Cocoa/Cocoa.h> |
|
#import <objc/runtime.h> |
|
|
|
@interface Injector: NSView @end |
|
|
|
@implementation Injector |
|
|
|
+ (void)load { |
|
|
|
[super load]; |
|
|
|
if (![[NSBundle mainBundle].bundleIdentifier containsString:@"SafariTechnologyPreview"]) |
|
return; |
|
|
|
NSLog(@"[SAFARI15FIXER] Swizzling in %@", [NSBundle mainBundle].bundleIdentifier); |
|
|
|
Class toolbarClass = NSClassFromString(@"ToolbarController"); |
|
|
|
SEL orgSel = NSSelectorFromString(@"updateBackForwardState"); |
|
Method orgMethod = class_getInstanceMethod(toolbarClass, orgSel); |
|
Method newMethod = class_getInstanceMethod(self, @selector(toolbar_updateBackForwardState)); |
|
|
|
class_addMethod(toolbarClass, @selector(toolbar_updateBackForwardState), |
|
method_getImplementation(orgMethod), |
|
method_getTypeEncoding(orgMethod)); |
|
class_replaceMethod(toolbarClass, orgSel, |
|
method_getImplementation(newMethod), |
|
method_getTypeEncoding(newMethod)); |
|
} |
|
|
|
- (id)delegate { return nil; } |
|
- (id)unifiedTabBar { return nil; } |
|
- (BOOL)isInteractivelyClosingTabs { return YES; } |
|
- (id)backForwardSegmentedControl { return nil; } |
|
- (void)_prepareBackForwardSegmentedControl:(NSSegmentedControl *)segment { } |
|
|
|
- (void)toolbar_updateBackForwardState { |
|
|
|
id _self = self; |
|
id _unifiedTabBar = [_self unifiedTabBar]; |
|
BOOL interactivelyClosing = [_unifiedTabBar isInteractivelyClosingTabs]; |
|
|
|
if (interactivelyClosing) return; |
|
|
|
id delegate = [_self delegate]; |
|
|
|
NSSegmentedControl *segment = [_self backForwardSegmentedControl]; |
|
|
|
if (segment.segmentCount != 2) { |
|
segment.segmentCount = 2; |
|
} |
|
|
|
[_self _prepareBackForwardSegmentedControl:segment]; |
|
} |
|
|
|
@end |