├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .gitmodules ├── Headers ├── ColorFunctions.h ├── Localization.h ├── MBProgressHUD.h ├── SponsorBlockRequest.h ├── SponsorBlockSettingsController.h ├── SponsorBlockViewController.h ├── SponsorSegment.h ├── SponsorSegmentView.h └── iSponsorBlock.h ├── LICENSE ├── MBProgressHUD.m ├── Makefile ├── README.md ├── SponsorBlockRequest.m ├── SponsorBlockSettingsController.m ├── SponsorBlockViewController.m ├── SponsorSegment.m ├── SponsorSegmentView.m ├── control ├── iSponsorBlock.plist ├── iSponsorBlock.xm └── layout └── Library └── Application Support └── iSponsorBlock.bundle ├── Info.plist ├── LogoSponsorBlocker128px.png ├── PlayerInfoIconSponsorBlocker256px-20@2x.png ├── SponsorAudio.m4a ├── de.lproj └── Localizable.strings ├── en.lproj └── Localizable.strings ├── es.lproj └── Localizable.strings ├── id.lproj └── Localizable.strings ├── ja.lproj └── Localizable.strings ├── ru.lproj └── Localizable.strings ├── sponsorblockend-20@2x.png ├── sponsorblocksettings-20@2x.png ├── sponsorblockstart-20@2x.png ├── tr.lproj └── Localizable.strings ├── vi.lproj └── Localizable.strings ├── zh-TW.lproj └── Localizable.strings └── zh_cn.lproj └── Localizable.strings /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: Galactic-Dev 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots** 23 | If applicable, add screenshots to help explain your problem. 24 | 25 | **Please complete the following information:** 26 | - iOS Version: [e.g. 14.3] 27 | - Device: [e.g. iPhone X] 28 | - YouTube Version [e.g. 16.11.3] 29 | - iSponsorBlock Version [e.g. 1.0-7] 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/theos-tweak 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=theos-tweak 3 | 4 | ### THEOS-Tweak ### 5 | ._* 6 | *.deb 7 | .debmake 8 | _ 9 | obj 10 | .theos 11 | .DS_Store 12 | 13 | ### XCode stuff 14 | *.xcworkspace 15 | 16 | # End of https://www.toptal.com/developers/gitignore/api/theos-tweak 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Headers/YouTubeHeader"] 2 | path = Headers/YouTubeHeader 3 | url = https://github.com/PoomSmart/YouTubeHeader 4 | -------------------------------------------------------------------------------- /Headers/ColorFunctions.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | //https://stackoverflow.com/a/26341062 4 | static NSString *hexFromUIColor(UIColor *color) { 5 | const CGFloat *components = CGColorGetComponents(color.CGColor); 6 | 7 | CGFloat r = components[0]; 8 | CGFloat g = components[1]; 9 | CGFloat b = components[2]; 10 | 11 | return [NSString stringWithFormat:@"#%02lX%02lX%02lX", 12 | lroundf(r * 255), 13 | lroundf(g * 255), 14 | lroundf(b * 255)]; 15 | } 16 | 17 | static CGFloat colorComponentFrom(NSString *string, NSUInteger start, NSUInteger length) { 18 | NSString *substring = [string substringWithRange: NSMakeRange(start, length)]; 19 | NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring]; 20 | unsigned hexComponent; 21 | [[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent]; 22 | return hexComponent / 255.0; 23 | } 24 | 25 | static UIColor *colorWithHexString(NSString *hexString) { 26 | NSString *colorString = [[hexString stringByReplacingOccurrencesOfString: @"#" withString: @""] uppercaseString]; 27 | 28 | CGFloat alpha, red, blue, green; 29 | 30 | // #RGB 31 | alpha = 1.0f; 32 | red = colorComponentFrom(colorString,0,2); 33 | green = colorComponentFrom(colorString,2,2); 34 | blue = colorComponentFrom(colorString,4,2); 35 | 36 | return [UIColor colorWithRed: red green: green blue: blue alpha: alpha]; 37 | } 38 | -------------------------------------------------------------------------------- /Headers/Localization.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | extern NSBundle *iSponsorBlockBundle(); 4 | 5 | static inline NSString *LOC(NSString *key) { 6 | NSBundle *tweakBundle = iSponsorBlockBundle(); 7 | return [tweakBundle localizedStringForKey:key value:nil table:nil]; 8 | } -------------------------------------------------------------------------------- /Headers/MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | // 2 | // MBProgressHUD.h 3 | // Version 1.2.0 4 | // Created by Matej Bukovinski on 2.4.09. 5 | // 6 | 7 | // This code is distributed under the terms and conditions of the MIT license. 8 | 9 | // Copyright © 2009-2020 Matej Bukovinski 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in 19 | // all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | // THE SOFTWARE. 28 | #import 29 | #import 30 | #import 31 | 32 | @class MBBackgroundView; 33 | @protocol MBProgressHUDDelegate; 34 | 35 | 36 | extern CGFloat const MBProgressMaxOffset; 37 | 38 | typedef NS_ENUM(NSInteger, MBProgressHUDMode) { 39 | /// UIActivityIndicatorView. 40 | MBProgressHUDModeIndeterminate, 41 | /// A round, pie-chart like, progress view. 42 | MBProgressHUDModeDeterminate, 43 | /// Horizontal progress bar. 44 | MBProgressHUDModeDeterminateHorizontalBar, 45 | /// Ring-shaped progress view. 46 | MBProgressHUDModeAnnularDeterminate, 47 | /// Shows a custom view. 48 | MBProgressHUDModeCustomView, 49 | /// Shows only labels. 50 | MBProgressHUDModeText 51 | }; 52 | 53 | typedef NS_ENUM(NSInteger, MBProgressHUDAnimation) { 54 | /// Opacity animation 55 | MBProgressHUDAnimationFade, 56 | /// Opacity + scale animation (zoom in when appearing zoom out when disappearing) 57 | MBProgressHUDAnimationZoom, 58 | /// Opacity + scale animation (zoom out style) 59 | MBProgressHUDAnimationZoomOut, 60 | /// Opacity + scale animation (zoom in style) 61 | MBProgressHUDAnimationZoomIn 62 | }; 63 | 64 | typedef NS_ENUM(NSInteger, MBProgressHUDBackgroundStyle) { 65 | /// Solid color background 66 | MBProgressHUDBackgroundStyleSolidColor, 67 | /// UIVisualEffectView or UIToolbar.layer background view 68 | MBProgressHUDBackgroundStyleBlur 69 | }; 70 | 71 | typedef void (^MBProgressHUDCompletionBlock)(void); 72 | 73 | 74 | NS_ASSUME_NONNULL_BEGIN 75 | 76 | 77 | /** 78 | * Displays a simple HUD window containing a progress indicator and two optional labels for short messages. 79 | * 80 | * This is a simple drop-in class for displaying a progress HUD view similar to Apple's private UIProgressHUD class. 81 | * The MBProgressHUD window spans over the entire space given to it by the initWithFrame: constructor and catches all 82 | * user input on this region, thereby preventing the user operations on components below the view. 83 | * 84 | * @note To still allow touches to pass through the HUD, you can set hud.userInteractionEnabled = NO. 85 | * @attention MBProgressHUD is a UI class and should therefore only be accessed on the main thread. 86 | */ 87 | @interface MBProgressHUD : UIView 88 | 89 | /** 90 | * Creates a new HUD, adds it to provided view and shows it. The counterpart to this method is hideHUDForView:animated:. 91 | * 92 | * @note This method sets removeFromSuperViewOnHide. The HUD will automatically be removed from the view hierarchy when hidden. 93 | * 94 | * @param view The view that the HUD will be added to 95 | * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use 96 | * animations while appearing. 97 | * @return A reference to the created HUD. 98 | * 99 | * @see hideHUDForView:animated: 100 | * @see animationType 101 | */ 102 | + (instancetype)showHUDAddedTo:(UIView *)view animated:(BOOL)animated; 103 | 104 | /// @name Showing and hiding 105 | 106 | /** 107 | * Finds the top-most HUD subview that hasn't finished and hides it. The counterpart to this method is showHUDAddedTo:animated:. 108 | * 109 | * @note This method sets removeFromSuperViewOnHide. The HUD will automatically be removed from the view hierarchy when hidden. 110 | * 111 | * @param view The view that is going to be searched for a HUD subview. 112 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 113 | * animations while disappearing. 114 | * @return YES if a HUD was found and removed, NO otherwise. 115 | * 116 | * @see showHUDAddedTo:animated: 117 | * @see animationType 118 | */ 119 | + (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated; 120 | 121 | /** 122 | * Finds the top-most HUD subview that hasn't finished and returns it. 123 | * 124 | * @param view The view that is going to be searched. 125 | * @return A reference to the last HUD subview discovered. 126 | */ 127 | + (nullable MBProgressHUD *)HUDForView:(UIView *)view NS_SWIFT_NAME(forView(_:)); 128 | 129 | /** 130 | * A convenience constructor that initializes the HUD with the view's bounds. Calls the designated constructor with 131 | * view.bounds as the parameter. 132 | * 133 | * @param view The view instance that will provide the bounds for the HUD. Should be the same instance as 134 | * the HUD's superview (i.e., the view that the HUD will be added to). 135 | */ 136 | - (instancetype)initWithView:(UIView *)view; 137 | 138 | /** 139 | * Displays the HUD. 140 | * 141 | * @note You need to make sure that the main thread completes its run loop soon after this method call so that 142 | * the user interface can be updated. Call this method when your task is already set up to be executed in a new thread 143 | * (e.g., when using something like NSOperation or making an asynchronous call like NSURLRequest). 144 | * 145 | * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use 146 | * animations while appearing. 147 | * 148 | * @see animationType 149 | */ 150 | - (void)showAnimated:(BOOL)animated; 151 | 152 | /** 153 | * Hides the HUD. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to 154 | * hide the HUD when your task completes. 155 | * 156 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 157 | * animations while disappearing. 158 | * 159 | * @see animationType 160 | */ 161 | - (void)hideAnimated:(BOOL)animated; 162 | 163 | /** 164 | * Hides the HUD after a delay. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to 165 | * hide the HUD when your task completes. 166 | * 167 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 168 | * animations while disappearing. 169 | * @param delay Delay in seconds until the HUD is hidden. 170 | * 171 | * @see animationType 172 | */ 173 | - (void)hideAnimated:(BOOL)animated afterDelay:(NSTimeInterval)delay; 174 | 175 | /** 176 | * The HUD delegate object. Receives HUD state notifications. 177 | */ 178 | @property (weak, nonatomic) id delegate; 179 | 180 | /** 181 | * Called after the HUD is hidden. 182 | */ 183 | @property (copy, nullable) MBProgressHUDCompletionBlock completionBlock; 184 | 185 | /** 186 | * Grace period is the time (in seconds) that the invoked method may be run without 187 | * showing the HUD. If the task finishes before the grace time runs out, the HUD will 188 | * not be shown at all. 189 | * This may be used to prevent HUD display for very short tasks. 190 | * Defaults to 0 (no grace time). 191 | * @note The graceTime needs to be set before the hud is shown. You thus can't use `showHUDAddedTo:animated:`, 192 | * but instead need to alloc / init the HUD, configure the grace time and than show it manually. 193 | */ 194 | @property (assign, nonatomic) NSTimeInterval graceTime; 195 | 196 | /** 197 | * The minimum time (in seconds) that the HUD is shown. 198 | * This avoids the problem of the HUD being shown and than instantly hidden. 199 | * Defaults to 0 (no minimum show time). 200 | */ 201 | @property (assign, nonatomic) NSTimeInterval minShowTime; 202 | 203 | /** 204 | * Removes the HUD from its parent view when hidden. 205 | * Defaults to NO. 206 | */ 207 | @property (assign, nonatomic) BOOL removeFromSuperViewOnHide; 208 | 209 | /// @name Appearance 210 | 211 | /** 212 | * MBProgressHUD operation mode. The default is MBProgressHUDModeIndeterminate. 213 | */ 214 | @property (assign, nonatomic) MBProgressHUDMode mode; 215 | 216 | /** 217 | * A color that gets forwarded to all labels and supported indicators. Also sets the tintColor 218 | * for custom views on iOS 7+. Set to nil to manage color individually. 219 | * Defaults to semi-translucent black on iOS 7 and later and white on earlier iOS versions. 220 | */ 221 | @property (strong, nonatomic, nullable) UIColor *contentColor UI_APPEARANCE_SELECTOR; 222 | 223 | /** 224 | * The animation type that should be used when the HUD is shown and hidden. 225 | */ 226 | @property (assign, nonatomic) MBProgressHUDAnimation animationType UI_APPEARANCE_SELECTOR; 227 | 228 | /** 229 | * The bezel offset relative to the center of the view. You can use MBProgressMaxOffset 230 | * and -MBProgressMaxOffset to move the HUD all the way to the screen edge in each direction. 231 | * E.g., CGPointMake(0.f, MBProgressMaxOffset) would position the HUD centered on the bottom edge. 232 | */ 233 | @property (assign, nonatomic) CGPoint offset UI_APPEARANCE_SELECTOR; 234 | 235 | /** 236 | * The amount of space between the HUD edge and the HUD elements (labels, indicators or custom views). 237 | * This also represents the minimum bezel distance to the edge of the HUD view. 238 | * Defaults to 20.f 239 | */ 240 | @property (assign, nonatomic) CGFloat margin UI_APPEARANCE_SELECTOR; 241 | 242 | /** 243 | * The minimum size of the HUD bezel. Defaults to CGSizeZero (no minimum size). 244 | */ 245 | @property (assign, nonatomic) CGSize minSize UI_APPEARANCE_SELECTOR; 246 | 247 | /** 248 | * Force the HUD dimensions to be equal if possible. 249 | */ 250 | @property (assign, nonatomic, getter = isSquare) BOOL square UI_APPEARANCE_SELECTOR; 251 | 252 | /** 253 | * When enabled, the bezel center gets slightly affected by the device accelerometer data. 254 | * Defaults to NO. 255 | * 256 | * @note This can cause main thread checker assertions on certain devices. https://github.com/jdg/MBProgressHUD/issues/552 257 | */ 258 | @property (assign, nonatomic, getter=areDefaultMotionEffectsEnabled) BOOL defaultMotionEffectsEnabled UI_APPEARANCE_SELECTOR; 259 | 260 | /// @name Progress 261 | 262 | /** 263 | * The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0. 264 | */ 265 | @property (assign, nonatomic) float progress; 266 | 267 | /// @name ProgressObject 268 | 269 | /** 270 | * The NSProgress object feeding the progress information to the progress indicator. 271 | */ 272 | @property (strong, nonatomic, nullable) NSProgress *progressObject; 273 | 274 | /// @name Views 275 | 276 | /** 277 | * The view containing the labels and indicator (or customView). 278 | */ 279 | @property (strong, nonatomic, readonly) MBBackgroundView *bezelView; 280 | 281 | /** 282 | * View covering the entire HUD area, placed behind bezelView. 283 | */ 284 | @property (strong, nonatomic, readonly) MBBackgroundView *backgroundView; 285 | 286 | /** 287 | * The UIView (e.g., a UIImageView) to be shown when the HUD is in MBProgressHUDModeCustomView. 288 | * The view should implement intrinsicContentSize for proper sizing. For best results use approximately 37 by 37 pixels. 289 | */ 290 | @property (strong, nonatomic, nullable) UIView *customView; 291 | 292 | /** 293 | * A label that holds an optional short message to be displayed below the activity indicator. The HUD is automatically resized to fit 294 | * the entire text. 295 | */ 296 | @property (strong, nonatomic, readonly) UILabel *label; 297 | 298 | /** 299 | * A label that holds an optional details message displayed below the labelText message. The details text can span multiple lines. 300 | */ 301 | @property (strong, nonatomic, readonly) UILabel *detailsLabel; 302 | 303 | /** 304 | * A button that is placed below the labels. Visible only if a target / action is added and a title is assigned.. 305 | */ 306 | @property (strong, nonatomic, readonly) UIButton *button; 307 | @property (strong, nonatomic, readonly) UIButton *cancelButton; 308 | 309 | @end 310 | 311 | 312 | @protocol MBProgressHUDDelegate 313 | 314 | @optional 315 | 316 | /** 317 | * Called after the HUD was fully hidden from the screen. 318 | */ 319 | - (void)hudWasHidden:(MBProgressHUD *)hud; 320 | 321 | @end 322 | 323 | 324 | /** 325 | * A progress view for showing definite progress by filling up a circle (pie chart). 326 | */ 327 | @interface MBRoundProgressView : UIView 328 | 329 | /** 330 | * Progress (0.0 to 1.0) 331 | */ 332 | @property (nonatomic, assign) float progress; 333 | 334 | /** 335 | * Indicator progress color. 336 | * Defaults to white [UIColor whiteColor]. 337 | */ 338 | @property (nonatomic, strong) UIColor *progressTintColor; 339 | 340 | /** 341 | * Indicator background (non-progress) color. 342 | * Only applicable on iOS versions older than iOS 7. 343 | * Defaults to translucent white (alpha 0.1). 344 | */ 345 | @property (nonatomic, strong) UIColor *backgroundTintColor; 346 | 347 | /* 348 | * Display mode - NO = round or YES = annular. Defaults to round. 349 | */ 350 | @property (nonatomic, assign, getter = isAnnular) BOOL annular; 351 | 352 | @end 353 | 354 | 355 | /** 356 | * A flat bar progress view. 357 | */ 358 | @interface MBBarProgressView : UIView 359 | 360 | /** 361 | * Progress (0.0 to 1.0) 362 | */ 363 | @property (nonatomic, assign) float progress; 364 | 365 | /** 366 | * Bar border line color. 367 | * Defaults to white [UIColor whiteColor]. 368 | */ 369 | @property (nonatomic, strong) UIColor *lineColor; 370 | 371 | /** 372 | * Bar background color. 373 | * Defaults to clear [UIColor clearColor]; 374 | */ 375 | @property (nonatomic, strong) UIColor *progressRemainingColor; 376 | 377 | /** 378 | * Bar progress color. 379 | * Defaults to white [UIColor whiteColor]. 380 | */ 381 | @property (nonatomic, strong) UIColor *progressColor; 382 | 383 | @end 384 | 385 | 386 | @interface MBBackgroundView : UIView 387 | 388 | /** 389 | * The background style. 390 | * Defaults to MBProgressHUDBackgroundStyleBlur. 391 | */ 392 | @property (nonatomic) MBProgressHUDBackgroundStyle style; 393 | 394 | /** 395 | * The blur effect style, when using MBProgressHUDBackgroundStyleBlur. 396 | * Defaults to UIBlurEffectStyleLight. 397 | */ 398 | @property (nonatomic) UIBlurEffectStyle blurEffectStyle; 399 | 400 | /** 401 | * The background color or the blur tint color. 402 | * 403 | * Defaults to nil on iOS 13 and later and 404 | * `[UIColor colorWithWhite:0.8f alpha:0.6f]` 405 | * on older systems. 406 | */ 407 | @property (nonatomic, strong, nullable) UIColor *color; 408 | 409 | @end 410 | 411 | NS_ASSUME_NONNULL_END 412 | -------------------------------------------------------------------------------- /Headers/SponsorBlockRequest.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "iSponsorBlock.h" 3 | #import 4 | 5 | @interface SponsorBlockRequest : NSObject 6 | +(void)getSponsorTimes:(NSString *)videoID completionTarget:(id)target completionSelector:(SEL)sel apiInstance:(NSString *)apiInstance; 7 | +(void)postSponsorTimes:(NSString *)videoID sponsorSegments:(NSArray *)segments userID:(NSString *)userID withViewController:(UIViewController *)viewController; 8 | +(void)normalVoteForSegment:(SponsorSegment *)segment userID:(NSString *)userID type:(BOOL)type withViewController:(UIViewController *)viewController; 9 | +(void)categoryVoteForSegment:(SponsorSegment *)segment userID:(NSString *)userID category:(NSString *)category withViewController:(UIViewController *)viewController; 10 | +(void)viewedVideoSponsorTime:(SponsorSegment *)segment; 11 | @end 12 | -------------------------------------------------------------------------------- /Headers/SponsorBlockSettingsController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import "ColorFunctions.h" 5 | 6 | @protocol HBColorPickerDelegate 7 | @optional -(void)colorPicker:(id)colorPicker didSelectColor:(UIColor *)color; 8 | @end 9 | 10 | @interface UIView () 11 | - (UIViewController *)_viewControllerForAncestor; 12 | @end 13 | 14 | @interface UITableViewCell () 15 | - (UITextField *)editableTextField; 16 | - (id)_indexPath; 17 | @end 18 | 19 | @interface UISegment : UIView 20 | @end 21 | 22 | @interface HBColorPickerConfiguration 23 | @property (nonatomic, assign) BOOL supportsAlpha; 24 | @end 25 | 26 | @interface HBColorPickerViewController : UIViewController 27 | @property (strong, nonatomic) NSObject *delegate; 28 | @property (strong, nonatomic) HBColorPickerConfiguration *configuration; 29 | @end 30 | 31 | @interface HBColorWell : UIControl 32 | @property (nonatomic, assign) BOOL isDragInteractionEnabled; 33 | @property (nonatomic, assign) BOOL isDropInteractionEnabled; 34 | @property (strong, nonatomic) UIColor *color; 35 | @end 36 | 37 | @interface SponsorBlockTableCell : UITableViewCell 38 | @property (strong, nonatomic) NSString *category; 39 | @property (strong, nonatomic) UIColor *color; 40 | @property (strong, nonatomic) HBColorWell *colorWell; 41 | @end 42 | 43 | @interface SponsorBlockSettingsController : UIViewController 44 | @property (nonatomic, strong) NSString *tweakTitle; 45 | @property (strong, nonatomic) UITableView *tableView; 46 | @property (strong, nonatomic) NSArray *sectionTitles; 47 | @property (strong, nonatomic) NSMutableDictionary *settings; 48 | @property (strong, nonatomic) NSString *settingsPath; 49 | - (void)enabledSwitchToggled:(UISwitch *)sender; 50 | - (void)switchToggled:(UISwitch *)sender; 51 | - (void)categorySegmentSelected:(UISegmentedControl *)segmentedControl; 52 | @end 53 | -------------------------------------------------------------------------------- /Headers/SponsorBlockViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "SponsorSegmentView.h" 3 | #import "iSponsorBlock.h" 4 | 5 | @interface SponsorBlockViewController : UIViewController 6 | @property (strong, nonatomic) YTPlayerViewController *playerViewController; 7 | @property (strong, nonatomic) UIViewController *previousParentViewController; 8 | @property (strong, nonatomic) YTMainAppControlsOverlayView *overlayView; 9 | @property (strong, nonatomic) UIButton *startEndSegmentButton; 10 | @property (strong, nonatomic) UILabel *segmentsInDatabaseLabel; 11 | @property (strong, nonatomic) UILabel *userSegmentsLabel; 12 | @property (strong, nonatomic) UIButton *submitSegmentsButton; 13 | @property (strong, nonatomic) NSMutableArray *sponsorSegmentViews; 14 | @property (strong, nonatomic) NSMutableArray *userSponsorSegmentViews; 15 | @property (strong, nonatomic) UILabel *whitelistChannelLabel; 16 | - (void)startEndSegmentButtonPressed:(UIButton *)sender; 17 | - (NSMutableArray *)segmentViewsForSegments:(NSArray *)segments editable:(BOOL)editable; 18 | - (void)setupViews; 19 | @end 20 | -------------------------------------------------------------------------------- /Headers/SponsorSegment.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface SponsorSegment : NSObject 5 | @property (nonatomic, assign) CGFloat startTime; 6 | @property (nonatomic, assign) CGFloat endTime; 7 | @property (strong, nonatomic) NSString *category; 8 | @property (strong, nonatomic) NSString *UUID; 9 | - (instancetype)initWithStartTime:(CGFloat)startTime endTime:(CGFloat)endTime category:(NSString *)category UUID:(NSString *)UUID; 10 | @end 11 | -------------------------------------------------------------------------------- /Headers/SponsorSegmentView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "SponsorSegment.h" 3 | #import "SponsorBlockRequest.h" 4 | 5 | @interface SponsorSegmentView : UIView 6 | @property (strong, nonatomic) SponsorSegment *sponsorSegment; 7 | @property (nonatomic, assign) BOOL editable; 8 | @property (strong, nonatomic) UILabel *segmentLabel; 9 | @property (strong, nonatomic) UILabel *categoryLabel; 10 | - (instancetype)initWithFrame:(CGRect)frame sponsorSegment:(SponsorSegment *)segment editable:(BOOL)editable; 11 | @end 12 | -------------------------------------------------------------------------------- /Headers/iSponsorBlock.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import "YouTubeHeader/QTMIcon.h" 5 | #import "YouTubeHeader/YTAppDelegate.h" 6 | #import "YouTubeHeader/YTAppViewControllerImpl.h" 7 | #import "YouTubeHeader/YTIChapterRenderer.h" 8 | #import "YouTubeHeader/YTIModularPlayerBarModel.h" 9 | #import "YouTubeHeader/YTInlinePlayerBarContainerView.h" 10 | #import "YouTubeHeader/YTInlinePlayerBarView.h" 11 | #import "YouTubeHeader/YTMainAppControlsOverlayView.h" 12 | #import "YouTubeHeader/YTMainAppVideoPlayerOverlayViewController.h" 13 | #import "YouTubeHeader/YTModularPlayerBarController.h" 14 | #import "YouTubeHeader/YTNGWatchLayerViewController.h" 15 | #import "YouTubeHeader/YTPageStyleController.h" 16 | #import "YouTubeHeader/YTPageStyleControllerImpl.h" 17 | #import "YouTubeHeader/YTPlayerBarProtocol.h" 18 | #import "YouTubeHeader/YTPlayerBarSegmentedProgressView.h" 19 | #import "YouTubeHeader/YTPlayerBarSegmentMarkerView.h" 20 | #import "YouTubeHeader/YTPlayerOverlayManager.h" 21 | #import "YouTubeHeader/YTPlayerView.h" 22 | #import "YouTubeHeader/YTPlayerViewController.h" 23 | #import "YouTubeHeader/YTRightNavigationButtons.h" 24 | #import "YouTubeHeader/YTSegmentableInlinePlayerBarView.h" 25 | #import "YouTubeHeader/YTSingleVideoTime.h" 26 | #import "YouTubeHeader/YTWatchLayerViewController.h" 27 | #import "MBProgressHUD.h" 28 | #import "SponsorSegment.h" 29 | #include 30 | 31 | // prefs 32 | extern BOOL kIsEnabled; 33 | extern NSString *kUserID; 34 | extern NSString *kAPIInstance; 35 | extern NSDictionary *kCategorySettings; 36 | extern CGFloat kMinimumDuration; 37 | extern BOOL kShowSkipNotice; 38 | extern BOOL kShowButtonsInPlayer; 39 | extern BOOL kHideStartEndButtonInPlayer; 40 | extern BOOL kShowModifiedTime; 41 | extern BOOL kSkipAudioNotification; 42 | extern BOOL kEnableSkipCountTracking; 43 | extern CGFloat kSkipNoticeDuration; 44 | extern NSMutableArray *kWhitelistedChannels; 45 | 46 | @interface YTInlinePlayerBarContainerView (iSB) 47 | @property (nonatomic, strong, readwrite) id modularPlayerBar; 48 | - (id)playerBar; 49 | @end 50 | 51 | @interface YTPlayerViewController (iSB) 52 | @property (strong, nonatomic) NSMutableArray *skipSegments; 53 | @property (nonatomic, assign) NSInteger currentSponsorSegment; 54 | @property (strong, nonatomic) MBProgressHUD *hud; 55 | @property (nonatomic, assign) NSInteger unskippedSegment; 56 | @property (strong, nonatomic) NSMutableArray *userSkipSegments; 57 | @property (nonatomic, assign) BOOL hudDisplayed; 58 | - (void)isb_scrubToTime:(CGFloat)time; 59 | - (void)isb_fixVisualGlitch; 60 | @end 61 | 62 | @interface YTMainAppControlsOverlayView (iSB) 63 | - (void)sponsorBlockButtonPressed:(YTQTMButton *)sender; 64 | - (void)sponsorStartedButtonPressed:(YTQTMButton *)sender; 65 | - (void)sponsorEndedButtonPressed:(YTQTMButton *)sender; 66 | - (void)presentSponsorBlockViewController; 67 | @property (retain, nonatomic) YTQTMButton *sponsorBlockButton; 68 | @property (retain, nonatomic) YTQTMButton *sponsorStartedEndedButton; 69 | @property (nonatomic, assign) BOOL isDisplayingSponsorBlockViewController; 70 | @end 71 | 72 | // Old class 73 | @interface YTIChapterRendererWrapper : NSObject 74 | - (instancetype)initWithStartTime:(CGFloat)arg1 endTime:(CGFloat)arg2 title:(NSString *)arg3; 75 | + (instancetype)chapterRendererWrapperWithRenderer:(YTIChapterRenderer *)arg1; 76 | @property (nonatomic, assign) CGFloat endTime; 77 | @end 78 | 79 | @interface YTPlayerBarSegmentedProgressView (iSB) 80 | @property (strong, nonatomic) NSMutableArray *sponsorMarkerViews; 81 | @property (nonatomic, retain) NSMutableArray *skipSegments; 82 | - (void)removeSponsorMarkers; 83 | @end 84 | 85 | @interface YTPlayerBarSegmentMarkerView (iSB) 86 | @property (nonatomic, assign) BOOL isSponsorMarker; 87 | @end 88 | 89 | @interface YTRightNavigationButtons (iSB) 90 | @property (strong, nonatomic) YTQTMButton *sponsorBlockButton; 91 | @end 92 | 93 | @interface YTInlinePlayerBarView (iSB) 94 | @property (strong, nonatomic) NSMutableArray *sponsorMarkerViews; 95 | @property (strong, nonatomic) NSMutableArray *skipSegments; 96 | - (void)removeSponsorMarkers; 97 | - (void)maybeCreateMarkerViewsISB; 98 | @end 99 | 100 | @interface YTSegmentableInlinePlayerBarView (iSB) 101 | @property (strong, nonatomic) NSMutableArray *sponsorMarkerViews; 102 | @property (strong, nonatomic) NSMutableArray *skipSegments; 103 | - (void)removeSponsorMarkers; 104 | - (void)maybeCreateMarkerViewsISB; 105 | @end 106 | 107 | @interface YTModularPlayerBarView (iSB) 108 | @property (strong, nonatomic) NSMutableArray *sponsorMarkerViews; 109 | @property (strong, nonatomic) NSMutableArray *skipSegments; 110 | - (void)removeSponsorMarkers; 111 | - (void)maybeCreateMarkerViewsISB; 112 | @end 113 | 114 | // Cercube 115 | @interface CADownloadObject : NSObject 116 | @property(readonly, nonatomic) NSString *filePath; 117 | @property(copy, nonatomic) NSString *fileName; // @dynamic fileName; 118 | @property(copy, nonatomic) NSString *videoId; 119 | @end 120 | 121 | @interface CADownloadObject_CADownloadObject_ : CADownloadObject 122 | @end 123 | 124 | @interface AVPlayerItem (Private) 125 | - (NSURL *)_URL; 126 | @end 127 | 128 | @interface AVQueuePlayer (iSB) 129 | @property (strong, nonatomic) NSMutableArray *skipSegments; 130 | @property (nonatomic, assign) NSInteger currentSponsorSegment; 131 | @property (strong, nonatomic) MBProgressHUD *hud; 132 | @property (nonatomic, assign) NSInteger unskippedSegment; 133 | @property (nonatomic, assign) BOOL isSeeking; 134 | @property (nonatomic, assign) NSInteger currentPlayerItem; 135 | @property (strong, nonatomic) id timeObserver; 136 | @property (strong, nonatomic) AVPlayerViewController *playerViewController; 137 | @property (strong, nonatomic) NSMutableArray *markerViews; 138 | @property (nonatomic, assign) BOOL hudDisplayed; 139 | - (void)sponsorBlockSetup; 140 | - (void)updateMarkerViews; 141 | @end 142 | 143 | @interface AVScrubber : UIView 144 | @end 145 | 146 | @interface AVPlaybackControlsView : UIView 147 | @property (strong, nonatomic) AVScrubber *scrubber; 148 | @end 149 | 150 | @interface AVPlayerViewControllerContentView : UIView 151 | @property (strong, nonatomic) AVPlaybackControlsView *playbackControlsView; 152 | @end 153 | 154 | @interface AVPlayerViewController () 155 | @property (strong, nonatomic) AVPlayerViewControllerContentView *contentView; 156 | @end 157 | 158 | @interface AVContentOverlayView : UIView 159 | @end 160 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MBProgressHUD.m: -------------------------------------------------------------------------------- 1 | // 2 | // MBProgressHUD.m 3 | // Version 1.2.0 4 | // Created by Matej Bukovinski on 2.4.09. 5 | // 6 | 7 | #import "Headers/MBProgressHUD.h" 8 | #import 9 | 10 | #define MBMainThreadAssert() NSAssert([NSThread isMainThread], @"MBProgressHUD needs to be accessed on the main thread."); 11 | 12 | CGFloat const MBProgressMaxOffset = 1000000.f; 13 | 14 | static const CGFloat MBDefaultPadding = 4.f; 15 | static const CGFloat MBDefaultLabelFontSize = 16.f; 16 | static const CGFloat MBDefaultDetailsLabelFontSize = 12.f; 17 | 18 | 19 | @interface MBProgressHUD () 20 | 21 | @property (nonatomic, assign) BOOL useAnimation; 22 | @property (nonatomic, assign, getter=hasFinished) BOOL finished; 23 | @property (nonatomic, strong) UIView *indicator; 24 | @property (nonatomic, strong) NSDate *showStarted; 25 | @property (nonatomic, strong) NSArray *paddingConstraints; 26 | @property (nonatomic, strong) NSArray *bezelConstraints; 27 | @property (nonatomic, strong) UIView *topSpacer; 28 | @property (nonatomic, strong) UIView *bottomSpacer; 29 | @property (nonatomic, strong) UIMotionEffectGroup *bezelMotionEffects; 30 | @property (nonatomic, weak) NSTimer *graceTimer; 31 | @property (nonatomic, weak) NSTimer *minShowTimer; 32 | @property (nonatomic, weak) NSTimer *hideDelayTimer; 33 | @property (nonatomic, weak) CADisplayLink *progressObjectDisplayLink; 34 | 35 | @end 36 | 37 | @interface MBProgressHUDRoundedButton : UIButton 38 | @end 39 | 40 | 41 | @implementation MBProgressHUD 42 | 43 | #pragma mark - Class methods 44 | 45 | + (instancetype)showHUDAddedTo:(UIView *)view animated:(BOOL)animated { 46 | MBProgressHUD *hud = [[self alloc] initWithView:view]; 47 | hud.removeFromSuperViewOnHide = YES; 48 | [view addSubview:hud]; 49 | [hud showAnimated:animated]; 50 | return hud; 51 | } 52 | 53 | + (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated { 54 | MBProgressHUD *hud = [self HUDForView:view]; 55 | if (hud != nil) { 56 | hud.removeFromSuperViewOnHide = YES; 57 | [hud hideAnimated:animated]; 58 | return YES; 59 | } 60 | return NO; 61 | } 62 | 63 | + (MBProgressHUD *)HUDForView:(UIView *)view { 64 | NSEnumerator *subviewsEnum = [view.subviews reverseObjectEnumerator]; 65 | for (UIView *subview in subviewsEnum) { 66 | if ([subview isKindOfClass:self]) { 67 | MBProgressHUD *hud = (MBProgressHUD *)subview; 68 | if (hud.hasFinished == NO) { 69 | return hud; 70 | } 71 | } 72 | } 73 | return nil; 74 | } 75 | 76 | #pragma mark - Lifecycle 77 | 78 | - (void)commonInit { 79 | // Set default values for properties 80 | _animationType = MBProgressHUDAnimationFade; 81 | _mode = MBProgressHUDModeIndeterminate; 82 | _margin = 20.0f; 83 | _defaultMotionEffectsEnabled = NO; 84 | 85 | if (@available(iOS 13.0, tvOS 13, *)) { 86 | _contentColor = [[UIColor labelColor] colorWithAlphaComponent:0.7f]; 87 | } else { 88 | _contentColor = [UIColor colorWithWhite:0.f alpha:0.7f]; 89 | } 90 | 91 | // Transparent background 92 | self.opaque = NO; 93 | self.backgroundColor = [UIColor clearColor]; 94 | // Make it invisible for now 95 | self.alpha = 0.0f; 96 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 97 | self.layer.allowsGroupOpacity = NO; 98 | 99 | [self setupViews]; 100 | [self updateIndicators]; 101 | [self registerForNotifications]; 102 | } 103 | 104 | - (instancetype)initWithFrame:(CGRect)frame { 105 | if ((self = [super initWithFrame:frame])) { 106 | [self commonInit]; 107 | } 108 | return self; 109 | } 110 | 111 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 112 | if ((self = [super initWithCoder:aDecoder])) { 113 | [self commonInit]; 114 | } 115 | return self; 116 | } 117 | 118 | - (id)initWithView:(UIView *)view { 119 | NSAssert(view, @"View must not be nil."); 120 | return [self initWithFrame:view.bounds]; 121 | } 122 | 123 | - (void)dealloc { 124 | [self unregisterFromNotifications]; 125 | } 126 | 127 | #pragma mark - Show & hide 128 | 129 | - (void)showAnimated:(BOOL)animated { 130 | MBMainThreadAssert(); 131 | [self.minShowTimer invalidate]; 132 | self.useAnimation = animated; 133 | self.finished = NO; 134 | // If the grace time is set, postpone the HUD display 135 | if (self.graceTime > 0.0) { 136 | NSTimer *timer = [NSTimer timerWithTimeInterval:self.graceTime target:self selector:@selector(handleGraceTimer:) userInfo:nil repeats:NO]; 137 | [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; 138 | self.graceTimer = timer; 139 | } 140 | // ... otherwise show the HUD immediately 141 | else { 142 | [self showUsingAnimation:self.useAnimation]; 143 | } 144 | } 145 | 146 | - (void)hideAnimated:(BOOL)animated { 147 | MBMainThreadAssert(); 148 | [self.graceTimer invalidate]; 149 | self.useAnimation = animated; 150 | self.finished = YES; 151 | // If the minShow time is set, calculate how long the HUD was shown, 152 | // and postpone the hiding operation if necessary 153 | if (self.minShowTime > 0.0 && self.showStarted) { 154 | NSTimeInterval interv = [[NSDate date] timeIntervalSinceDate:self.showStarted]; 155 | if (interv < self.minShowTime) { 156 | NSTimer *timer = [NSTimer timerWithTimeInterval:(self.minShowTime - interv) target:self selector:@selector(handleMinShowTimer:) userInfo:nil repeats:NO]; 157 | [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; 158 | self.minShowTimer = timer; 159 | return; 160 | } 161 | } 162 | // ... otherwise hide the HUD immediately 163 | [self hideUsingAnimation:self.useAnimation]; 164 | } 165 | 166 | - (void)hideAnimated:(BOOL)animated afterDelay:(NSTimeInterval)delay { 167 | // Cancel any scheduled hideAnimated:afterDelay: calls 168 | [self.hideDelayTimer invalidate]; 169 | 170 | NSTimer *timer = [NSTimer timerWithTimeInterval:delay target:self selector:@selector(handleHideTimer:) userInfo:@(animated) repeats:NO]; 171 | [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; 172 | self.hideDelayTimer = timer; 173 | } 174 | 175 | #pragma mark - Timer callbacks 176 | 177 | - (void)handleGraceTimer:(NSTimer *)theTimer { 178 | // Show the HUD only if the task is still running 179 | if (!self.hasFinished) { 180 | [self showUsingAnimation:self.useAnimation]; 181 | } 182 | } 183 | 184 | - (void)handleMinShowTimer:(NSTimer *)theTimer { 185 | [self hideUsingAnimation:self.useAnimation]; 186 | } 187 | 188 | - (void)handleHideTimer:(NSTimer *)timer { 189 | [self hideAnimated:[timer.userInfo boolValue]]; 190 | } 191 | 192 | #pragma mark - View Hierrarchy 193 | 194 | - (void)didMoveToSuperview { 195 | [self updateForCurrentOrientationAnimated:NO]; 196 | } 197 | 198 | #pragma mark - Internal show & hide operations 199 | 200 | - (void)showUsingAnimation:(BOOL)animated { 201 | // Cancel any previous animations 202 | [self.bezelView.layer removeAllAnimations]; 203 | [self.backgroundView.layer removeAllAnimations]; 204 | 205 | // Cancel any scheduled hideAnimated:afterDelay: calls 206 | [self.hideDelayTimer invalidate]; 207 | 208 | self.showStarted = [NSDate date]; 209 | self.alpha = 1.f; 210 | 211 | // Needed in case we hide and re-show with the same NSProgress object attached. 212 | [self setNSProgressDisplayLinkEnabled:YES]; 213 | 214 | // Set up motion effects only at this point to avoid needlessly 215 | // creating the effect if it was disabled after initialization. 216 | [self updateBezelMotionEffects]; 217 | 218 | if (animated) { 219 | [self animateIn:YES withType:self.animationType completion:NULL]; 220 | } else { 221 | self.bezelView.alpha = 1.f; 222 | self.backgroundView.alpha = 1.f; 223 | } 224 | } 225 | 226 | - (void)hideUsingAnimation:(BOOL)animated { 227 | // Cancel any scheduled hideAnimated:afterDelay: calls. 228 | // This needs to happen here instead of in done, 229 | // to avoid races if another hideAnimated:afterDelay: 230 | // call comes in while the HUD is animating out. 231 | [self.hideDelayTimer invalidate]; 232 | 233 | if (animated && self.showStarted) { 234 | self.showStarted = nil; 235 | [self animateIn:NO withType:self.animationType completion:^(BOOL finished) { 236 | [self done]; 237 | }]; 238 | } else { 239 | self.showStarted = nil; 240 | self.bezelView.alpha = 0.f; 241 | self.backgroundView.alpha = 1.f; 242 | [self done]; 243 | } 244 | } 245 | 246 | - (void)animateIn:(BOOL)animatingIn withType:(MBProgressHUDAnimation)type completion:(void(^)(BOOL finished))completion { 247 | // Automatically determine the correct zoom animation type 248 | if (type == MBProgressHUDAnimationZoom) { 249 | type = animatingIn ? MBProgressHUDAnimationZoomIn : MBProgressHUDAnimationZoomOut; 250 | } 251 | 252 | CGAffineTransform small = CGAffineTransformMakeScale(0.5f, 0.5f); 253 | CGAffineTransform large = CGAffineTransformMakeScale(1.5f, 1.5f); 254 | 255 | // Set starting state 256 | UIView *bezelView = self.bezelView; 257 | if (animatingIn && bezelView.alpha == 0.f && type == MBProgressHUDAnimationZoomIn) { 258 | bezelView.transform = small; 259 | } else if (animatingIn && bezelView.alpha == 0.f && type == MBProgressHUDAnimationZoomOut) { 260 | bezelView.transform = large; 261 | } 262 | 263 | // Perform animations 264 | dispatch_block_t animations = ^{ 265 | if (animatingIn) { 266 | bezelView.transform = CGAffineTransformIdentity; 267 | } else if (!animatingIn && type == MBProgressHUDAnimationZoomIn) { 268 | bezelView.transform = large; 269 | } else if (!animatingIn && type == MBProgressHUDAnimationZoomOut) { 270 | bezelView.transform = small; 271 | } 272 | CGFloat alpha = animatingIn ? 1.f : 0.f; 273 | bezelView.alpha = alpha; 274 | self.backgroundView.alpha = alpha; 275 | }; 276 | [UIView animateWithDuration:0.3 delay:0. usingSpringWithDamping:1.f initialSpringVelocity:0.f options:UIViewAnimationOptionBeginFromCurrentState animations:animations completion:completion]; 277 | } 278 | 279 | - (void)done { 280 | [self setNSProgressDisplayLinkEnabled:NO]; 281 | 282 | if (self.hasFinished) { 283 | self.alpha = 0.0f; 284 | if (self.removeFromSuperViewOnHide) { 285 | [self removeFromSuperview]; 286 | } 287 | } 288 | MBProgressHUDCompletionBlock completionBlock = self.completionBlock; 289 | if (completionBlock) { 290 | completionBlock(); 291 | } 292 | id delegate = self.delegate; 293 | if ([delegate respondsToSelector:@selector(hudWasHidden:)]) { 294 | [delegate performSelector:@selector(hudWasHidden:) withObject:self]; 295 | } 296 | } 297 | 298 | #pragma mark - UI 299 | 300 | - (void)setupViews { 301 | UIColor *defaultColor = self.contentColor; 302 | 303 | MBBackgroundView *backgroundView = [[MBBackgroundView alloc] initWithFrame:self.bounds]; 304 | backgroundView.style = MBProgressHUDBackgroundStyleSolidColor; 305 | backgroundView.backgroundColor = [UIColor clearColor]; 306 | backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 307 | backgroundView.alpha = 0.f; 308 | [self addSubview:backgroundView]; 309 | _backgroundView = backgroundView; 310 | 311 | MBBackgroundView *bezelView = [MBBackgroundView new]; 312 | bezelView.translatesAutoresizingMaskIntoConstraints = NO; 313 | bezelView.layer.cornerRadius = 5.f; 314 | bezelView.alpha = 0.f; 315 | [self addSubview:bezelView]; 316 | _bezelView = bezelView; 317 | 318 | UILabel *label = [UILabel new]; 319 | label.adjustsFontSizeToFitWidth = NO; 320 | label.textAlignment = NSTextAlignmentCenter; 321 | label.textColor = defaultColor; 322 | label.font = [UIFont boldSystemFontOfSize:MBDefaultLabelFontSize]; 323 | label.opaque = NO; 324 | label.backgroundColor = [UIColor clearColor]; 325 | _label = label; 326 | 327 | UILabel *detailsLabel = [UILabel new]; 328 | detailsLabel.adjustsFontSizeToFitWidth = NO; 329 | detailsLabel.textAlignment = NSTextAlignmentCenter; 330 | detailsLabel.textColor = defaultColor; 331 | detailsLabel.numberOfLines = 0; 332 | detailsLabel.font = [UIFont boldSystemFontOfSize:MBDefaultDetailsLabelFontSize]; 333 | detailsLabel.opaque = NO; 334 | detailsLabel.backgroundColor = [UIColor clearColor]; 335 | _detailsLabel = detailsLabel; 336 | 337 | UIButton *button = [MBProgressHUDRoundedButton buttonWithType:UIButtonTypeCustom]; 338 | button.titleLabel.textAlignment = NSTextAlignmentCenter; 339 | button.titleLabel.font = [UIFont boldSystemFontOfSize:MBDefaultDetailsLabelFontSize]; 340 | [button setTitleColor:defaultColor forState:UIControlStateNormal]; 341 | _button = button; 342 | 343 | for (UIView *view in @[label, detailsLabel, button]) { 344 | view.translatesAutoresizingMaskIntoConstraints = NO; 345 | [view setContentCompressionResistancePriority:998.f forAxis:UILayoutConstraintAxisHorizontal]; 346 | [view setContentCompressionResistancePriority:998.f forAxis:UILayoutConstraintAxisVertical]; 347 | [bezelView addSubview:view]; 348 | } 349 | 350 | UIView *topSpacer = [UIView new]; 351 | topSpacer.translatesAutoresizingMaskIntoConstraints = NO; 352 | topSpacer.hidden = YES; 353 | [bezelView addSubview:topSpacer]; 354 | _topSpacer = topSpacer; 355 | 356 | UIView *bottomSpacer = [UIView new]; 357 | bottomSpacer.translatesAutoresizingMaskIntoConstraints = NO; 358 | bottomSpacer.hidden = YES; 359 | [bezelView addSubview:bottomSpacer]; 360 | _bottomSpacer = bottomSpacer; 361 | } 362 | 363 | - (void)updateIndicators { 364 | UIView *indicator = self.indicator; 365 | BOOL isActivityIndicator = [indicator isKindOfClass:[UIActivityIndicatorView class]]; 366 | BOOL isRoundIndicator = [indicator isKindOfClass:[MBRoundProgressView class]]; 367 | 368 | MBProgressHUDMode mode = self.mode; 369 | if (mode == MBProgressHUDModeIndeterminate) { 370 | if (!isActivityIndicator) { 371 | // Update to indeterminate indicator 372 | UIActivityIndicatorView *activityIndicator; 373 | [indicator removeFromSuperview]; 374 | #if !TARGET_OS_MACCATALYST 375 | if (@available(iOS 13.0, tvOS 13.0, *)) { 376 | #endif 377 | activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge]; 378 | activityIndicator.color = [UIColor whiteColor]; 379 | #if !TARGET_OS_MACCATALYST 380 | } else { 381 | activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 382 | } 383 | #endif 384 | [activityIndicator startAnimating]; 385 | indicator = activityIndicator; 386 | [self.bezelView addSubview:indicator]; 387 | } 388 | } 389 | else if (mode == MBProgressHUDModeDeterminateHorizontalBar) { 390 | // Update to bar determinate indicator 391 | [indicator removeFromSuperview]; 392 | indicator = [[MBBarProgressView alloc] init]; 393 | [self.bezelView addSubview:indicator]; 394 | } 395 | else if (mode == MBProgressHUDModeDeterminate || mode == MBProgressHUDModeAnnularDeterminate) { 396 | if (!isRoundIndicator) { 397 | // Update to determinante indicator 398 | [indicator removeFromSuperview]; 399 | indicator = [[MBRoundProgressView alloc] init]; 400 | [self.bezelView addSubview:indicator]; 401 | } 402 | if (mode == MBProgressHUDModeAnnularDeterminate) { 403 | [(MBRoundProgressView *)indicator setAnnular:YES]; 404 | } 405 | } 406 | else if (mode == MBProgressHUDModeCustomView && self.customView != indicator) { 407 | // Update custom view indicator 408 | [indicator removeFromSuperview]; 409 | indicator = self.customView; 410 | [self.bezelView addSubview:indicator]; 411 | } 412 | else if (mode == MBProgressHUDModeText) { 413 | [indicator removeFromSuperview]; 414 | indicator = nil; 415 | } 416 | indicator.translatesAutoresizingMaskIntoConstraints = NO; 417 | self.indicator = indicator; 418 | 419 | if ([indicator respondsToSelector:@selector(setProgress:)]) { 420 | [(id)indicator setValue:@(self.progress) forKey:@"progress"]; 421 | } 422 | 423 | [indicator setContentCompressionResistancePriority:998.f forAxis:UILayoutConstraintAxisHorizontal]; 424 | [indicator setContentCompressionResistancePriority:998.f forAxis:UILayoutConstraintAxisVertical]; 425 | 426 | [self updateViewsForColor:self.contentColor]; 427 | [self setNeedsUpdateConstraints]; 428 | } 429 | 430 | - (void)updateViewsForColor:(UIColor *)color { 431 | if (!color) return; 432 | 433 | self.label.textColor = color; 434 | self.detailsLabel.textColor = color; 435 | [self.button setTitleColor:color forState:UIControlStateNormal]; 436 | 437 | // UIAppearance settings are prioritized. If they are preset the set color is ignored. 438 | 439 | UIView *indicator = self.indicator; 440 | if ([indicator isKindOfClass:[UIActivityIndicatorView class]]) { 441 | UIActivityIndicatorView *appearance = nil; 442 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 90000 443 | appearance = [UIActivityIndicatorView appearanceWhenContainedIn:[MBProgressHUD class], nil]; 444 | #else 445 | // For iOS 9+ 446 | appearance = [UIActivityIndicatorView appearanceWhenContainedInInstancesOfClasses:@[[MBProgressHUD class]]]; 447 | #endif 448 | 449 | if (appearance.color == nil) { 450 | ((UIActivityIndicatorView *)indicator).color = color; 451 | } 452 | } else if ([indicator isKindOfClass:[MBRoundProgressView class]]) { 453 | MBRoundProgressView *appearance = nil; 454 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 90000 455 | appearance = [MBRoundProgressView appearanceWhenContainedIn:[MBProgressHUD class], nil]; 456 | #else 457 | appearance = [MBRoundProgressView appearanceWhenContainedInInstancesOfClasses:@[[MBProgressHUD class]]]; 458 | #endif 459 | if (appearance.progressTintColor == nil) { 460 | ((MBRoundProgressView *)indicator).progressTintColor = color; 461 | } 462 | if (appearance.backgroundTintColor == nil) { 463 | ((MBRoundProgressView *)indicator).backgroundTintColor = [color colorWithAlphaComponent:0.1]; 464 | } 465 | } else if ([indicator isKindOfClass:[MBBarProgressView class]]) { 466 | MBBarProgressView *appearance = nil; 467 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 90000 468 | appearance = [MBBarProgressView appearanceWhenContainedIn:[MBProgressHUD class], nil]; 469 | #else 470 | appearance = [MBBarProgressView appearanceWhenContainedInInstancesOfClasses:@[[MBProgressHUD class]]]; 471 | #endif 472 | if (appearance.progressColor == nil) { 473 | ((MBBarProgressView *)indicator).progressColor = color; 474 | } 475 | if (appearance.lineColor == nil) { 476 | ((MBBarProgressView *)indicator).lineColor = color; 477 | } 478 | } else { 479 | [indicator setTintColor:color]; 480 | } 481 | } 482 | 483 | - (void)updateBezelMotionEffects { 484 | MBBackgroundView *bezelView = self.bezelView; 485 | UIMotionEffectGroup *bezelMotionEffects = self.bezelMotionEffects; 486 | 487 | if (self.defaultMotionEffectsEnabled && !bezelMotionEffects) { 488 | CGFloat effectOffset = 10.f; 489 | UIInterpolatingMotionEffect *effectX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; 490 | effectX.maximumRelativeValue = @(effectOffset); 491 | effectX.minimumRelativeValue = @(-effectOffset); 492 | 493 | UIInterpolatingMotionEffect *effectY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis]; 494 | effectY.maximumRelativeValue = @(effectOffset); 495 | effectY.minimumRelativeValue = @(-effectOffset); 496 | 497 | UIMotionEffectGroup *group = [[UIMotionEffectGroup alloc] init]; 498 | group.motionEffects = @[effectX, effectY]; 499 | 500 | self.bezelMotionEffects = group; 501 | [bezelView addMotionEffect:group]; 502 | } else if (bezelMotionEffects) { 503 | self.bezelMotionEffects = nil; 504 | [bezelView removeMotionEffect:bezelMotionEffects]; 505 | } 506 | } 507 | 508 | #pragma mark - Layout 509 | 510 | - (void)updateConstraints { 511 | UIView *bezel = self.bezelView; 512 | UIView *topSpacer = self.topSpacer; 513 | UIView *bottomSpacer = self.bottomSpacer; 514 | CGFloat margin = self.margin; 515 | NSMutableArray *bezelConstraints = [NSMutableArray array]; 516 | NSDictionary *metrics = @{@"margin": @(margin)}; 517 | 518 | NSMutableArray *subviews = [NSMutableArray arrayWithObjects:self.topSpacer, self.label, self.detailsLabel, self.button, self.bottomSpacer, nil]; 519 | if (self.indicator) [subviews insertObject:self.indicator atIndex:1]; 520 | 521 | // Remove existing constraints 522 | [self removeConstraints:self.constraints]; 523 | [topSpacer removeConstraints:topSpacer.constraints]; 524 | [bottomSpacer removeConstraints:bottomSpacer.constraints]; 525 | if (self.bezelConstraints) { 526 | [bezel removeConstraints:self.bezelConstraints]; 527 | self.bezelConstraints = nil; 528 | } 529 | 530 | // Center bezel in container (self), applying the offset if set 531 | CGPoint offset = self.offset; 532 | NSMutableArray *centeringConstraints = [NSMutableArray array]; 533 | [centeringConstraints addObject:[NSLayoutConstraint constraintWithItem:bezel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.f constant:offset.x]]; 534 | [centeringConstraints addObject:[NSLayoutConstraint constraintWithItem:bezel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.f constant:offset.y]]; 535 | [self applyPriority:998.f toConstraints:centeringConstraints]; 536 | [self addConstraints:centeringConstraints]; 537 | 538 | // Ensure minimum side margin is kept 539 | NSMutableArray *sideConstraints = [NSMutableArray array]; 540 | [sideConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"|-(>=margin)-[bezel]-(>=margin)-|" options:0 metrics:metrics views:NSDictionaryOfVariableBindings(bezel)]]; 541 | [sideConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(>=margin)-[bezel]-(>=margin)-|" options:0 metrics:metrics views:NSDictionaryOfVariableBindings(bezel)]]; 542 | [self applyPriority:999.f toConstraints:sideConstraints]; 543 | [self addConstraints:sideConstraints]; 544 | 545 | // Minimum bezel size, if set 546 | CGSize minimumSize = self.minSize; 547 | if (!CGSizeEqualToSize(minimumSize, CGSizeZero)) { 548 | NSMutableArray *minSizeConstraints = [NSMutableArray array]; 549 | [minSizeConstraints addObject:[NSLayoutConstraint constraintWithItem:bezel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.f constant:minimumSize.width]]; 550 | [minSizeConstraints addObject:[NSLayoutConstraint constraintWithItem:bezel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.f constant:minimumSize.height]]; 551 | [self applyPriority:997.f toConstraints:minSizeConstraints]; 552 | [bezelConstraints addObjectsFromArray:minSizeConstraints]; 553 | } 554 | 555 | // Square aspect ratio, if set 556 | if (self.square) { 557 | NSLayoutConstraint *square = [NSLayoutConstraint constraintWithItem:bezel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:bezel attribute:NSLayoutAttributeWidth multiplier:1.f constant:0]; 558 | square.priority = 997.f; 559 | [bezelConstraints addObject:square]; 560 | } 561 | 562 | // Top and bottom spacing 563 | [topSpacer addConstraint:[NSLayoutConstraint constraintWithItem:topSpacer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.f constant:margin]]; 564 | [bottomSpacer addConstraint:[NSLayoutConstraint constraintWithItem:bottomSpacer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.f constant:margin]]; 565 | // Top and bottom spaces should be equal 566 | [bezelConstraints addObject:[NSLayoutConstraint constraintWithItem:topSpacer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:bottomSpacer attribute:NSLayoutAttributeHeight multiplier:1.f constant:0.f]]; 567 | 568 | // Layout subviews in bezel 569 | NSMutableArray *paddingConstraints = [NSMutableArray new]; 570 | [subviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { 571 | // Center in bezel 572 | [bezelConstraints addObject:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:bezel attribute:NSLayoutAttributeCenterX multiplier:1.f constant:0.f]]; 573 | // Ensure the minimum edge margin is kept 574 | [bezelConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"|-(>=margin)-[view]-(>=margin)-|" options:0 metrics:metrics views:NSDictionaryOfVariableBindings(view)]]; 575 | // Element spacing 576 | if (idx == 0) { 577 | // First, ensure spacing to bezel edge 578 | [bezelConstraints addObject:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:bezel attribute:NSLayoutAttributeTop multiplier:1.f constant:0.f]]; 579 | } else if (idx == subviews.count - 1) { 580 | // Last, ensure spacing to bezel edge 581 | [bezelConstraints addObject:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:bezel attribute:NSLayoutAttributeBottom multiplier:1.f constant:0.f]]; 582 | } 583 | if (idx > 0) { 584 | // Has previous 585 | NSLayoutConstraint *padding = [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:subviews[idx - 1] attribute:NSLayoutAttributeBottom multiplier:1.f constant:0.f]; 586 | [bezelConstraints addObject:padding]; 587 | [paddingConstraints addObject:padding]; 588 | } 589 | }]; 590 | 591 | [bezel addConstraints:bezelConstraints]; 592 | self.bezelConstraints = bezelConstraints; 593 | 594 | self.paddingConstraints = [paddingConstraints copy]; 595 | [self updatePaddingConstraints]; 596 | 597 | [super updateConstraints]; 598 | } 599 | 600 | - (void)layoutSubviews { 601 | // There is no need to update constraints if they are going to 602 | // be recreated in [super layoutSubviews] due to needsUpdateConstraints being set. 603 | // This also avoids an issue on iOS 8, where updatePaddingConstraints 604 | // would trigger a zombie object access. 605 | if (!self.needsUpdateConstraints) { 606 | [self updatePaddingConstraints]; 607 | } 608 | [super layoutSubviews]; 609 | } 610 | 611 | - (void)updatePaddingConstraints { 612 | // Set padding dynamically, depending on whether the view is visible or not 613 | __block BOOL hasVisibleAncestors = NO; 614 | [self.paddingConstraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *padding, NSUInteger idx, BOOL *stop) { 615 | UIView *firstView = (UIView *)padding.firstItem; 616 | UIView *secondView = (UIView *)padding.secondItem; 617 | BOOL firstVisible = !firstView.hidden && !CGSizeEqualToSize(firstView.intrinsicContentSize, CGSizeZero); 618 | BOOL secondVisible = !secondView.hidden && !CGSizeEqualToSize(secondView.intrinsicContentSize, CGSizeZero); 619 | // Set if both views are visible or if there's a visible view on top that doesn't have padding 620 | // added relative to the current view yet 621 | padding.constant = (firstVisible && (secondVisible || hasVisibleAncestors)) ? MBDefaultPadding : 0.f; 622 | hasVisibleAncestors |= secondVisible; 623 | }]; 624 | } 625 | 626 | - (void)applyPriority:(UILayoutPriority)priority toConstraints:(NSArray *)constraints { 627 | for (NSLayoutConstraint *constraint in constraints) { 628 | constraint.priority = priority; 629 | } 630 | } 631 | 632 | #pragma mark - Properties 633 | 634 | - (void)setMode:(MBProgressHUDMode)mode { 635 | if (mode != _mode) { 636 | _mode = mode; 637 | [self updateIndicators]; 638 | } 639 | } 640 | 641 | - (void)setCustomView:(UIView *)customView { 642 | if (customView != _customView) { 643 | _customView = customView; 644 | if (self.mode == MBProgressHUDModeCustomView) { 645 | [self updateIndicators]; 646 | } 647 | } 648 | } 649 | 650 | - (void)setOffset:(CGPoint)offset { 651 | if (!CGPointEqualToPoint(offset, _offset)) { 652 | _offset = offset; 653 | [self setNeedsUpdateConstraints]; 654 | } 655 | } 656 | 657 | - (void)setMargin:(CGFloat)margin { 658 | if (margin != _margin) { 659 | _margin = margin; 660 | [self setNeedsUpdateConstraints]; 661 | } 662 | } 663 | 664 | - (void)setMinSize:(CGSize)minSize { 665 | if (!CGSizeEqualToSize(minSize, _minSize)) { 666 | _minSize = minSize; 667 | [self setNeedsUpdateConstraints]; 668 | } 669 | } 670 | 671 | - (void)setSquare:(BOOL)square { 672 | if (square != _square) { 673 | _square = square; 674 | [self setNeedsUpdateConstraints]; 675 | } 676 | } 677 | 678 | - (void)setProgressObjectDisplayLink:(CADisplayLink *)progressObjectDisplayLink { 679 | if (progressObjectDisplayLink != _progressObjectDisplayLink) { 680 | [_progressObjectDisplayLink invalidate]; 681 | 682 | _progressObjectDisplayLink = progressObjectDisplayLink; 683 | 684 | [_progressObjectDisplayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; 685 | } 686 | } 687 | 688 | - (void)setProgressObject:(NSProgress *)progressObject { 689 | if (progressObject != _progressObject) { 690 | _progressObject = progressObject; 691 | [self setNSProgressDisplayLinkEnabled:YES]; 692 | } 693 | } 694 | 695 | - (void)setProgress:(float)progress { 696 | if (progress != _progress) { 697 | _progress = progress; 698 | UIView *indicator = self.indicator; 699 | if ([indicator respondsToSelector:@selector(setProgress:)]) { 700 | [(id)indicator setValue:@(self.progress) forKey:@"progress"]; 701 | } 702 | } 703 | } 704 | 705 | - (void)setContentColor:(UIColor *)contentColor { 706 | if (contentColor != _contentColor && ![contentColor isEqual:_contentColor]) { 707 | _contentColor = contentColor; 708 | [self updateViewsForColor:contentColor]; 709 | } 710 | } 711 | 712 | - (void)setDefaultMotionEffectsEnabled:(BOOL)defaultMotionEffectsEnabled { 713 | if (defaultMotionEffectsEnabled != _defaultMotionEffectsEnabled) { 714 | _defaultMotionEffectsEnabled = defaultMotionEffectsEnabled; 715 | [self updateBezelMotionEffects]; 716 | } 717 | } 718 | 719 | #pragma mark - NSProgress 720 | 721 | - (void)setNSProgressDisplayLinkEnabled:(BOOL)enabled { 722 | // We're using CADisplayLink, because NSProgress can change very quickly and observing it may starve the main thread, 723 | // so we're refreshing the progress only every frame draw 724 | if (enabled && self.progressObject) { 725 | // Only create if not already active. 726 | if (!self.progressObjectDisplayLink) { 727 | self.progressObjectDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateProgressFromProgressObject)]; 728 | } 729 | } else { 730 | self.progressObjectDisplayLink = nil; 731 | } 732 | } 733 | 734 | - (void)updateProgressFromProgressObject { 735 | self.progress = self.progressObject.fractionCompleted; 736 | } 737 | 738 | #pragma mark - Notifications 739 | 740 | - (void)registerForNotifications { 741 | #if !TARGET_OS_TV && !TARGET_OS_MACCATALYST 742 | NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; 743 | 744 | [nc addObserver:self selector:@selector(statusBarOrientationDidChange:) 745 | name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; 746 | #endif 747 | } 748 | 749 | - (void)unregisterFromNotifications { 750 | #if !TARGET_OS_TV && !TARGET_OS_MACCATALYST 751 | NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; 752 | [nc removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; 753 | #endif 754 | } 755 | 756 | #if !TARGET_OS_TV && !TARGET_OS_MACCATALYST 757 | - (void)statusBarOrientationDidChange:(NSNotification *)notification { 758 | UIView *superview = self.superview; 759 | if (!superview) { 760 | return; 761 | } else { 762 | [self updateForCurrentOrientationAnimated:YES]; 763 | } 764 | } 765 | #endif 766 | 767 | - (void)updateForCurrentOrientationAnimated:(BOOL)animated { 768 | // Stay in sync with the superview in any case 769 | if (self.superview) { 770 | self.frame = self.superview.bounds; 771 | } 772 | 773 | // Not needed on iOS 8+, compile out when the deployment target allows, 774 | // to avoid sharedApplication problems on extension targets 775 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000 776 | // Only needed pre iOS 8 when added to a window 777 | BOOL iOS8OrLater = kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_8_0; 778 | if (iOS8OrLater || ![self.superview isKindOfClass:[UIWindow class]]) return; 779 | 780 | // Make extension friendly. Will not get called on extensions (iOS 8+) due to the above check. 781 | // This just ensures we don't get a warning about extension-unsafe API. 782 | Class UIApplicationClass = NSClassFromString(@"UIApplication"); 783 | if (!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) return; 784 | 785 | UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)]; 786 | UIInterfaceOrientation orientation = application.statusBarOrientation; 787 | CGFloat radians = 0; 788 | 789 | if (UIInterfaceOrientationIsLandscape(orientation)) { 790 | radians = orientation == UIInterfaceOrientationLandscapeLeft ? -(CGFloat)M_PI_2 : (CGFloat)M_PI_2; 791 | // Window coordinates differ! 792 | self.bounds = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.width); 793 | } else { 794 | radians = orientation == UIInterfaceOrientationPortraitUpsideDown ? (CGFloat)M_PI : 0.f; 795 | } 796 | 797 | if (animated) { 798 | [UIView animateWithDuration:0.3 animations:^{ 799 | self.transform = CGAffineTransformMakeRotation(radians); 800 | }]; 801 | } else { 802 | self.transform = CGAffineTransformMakeRotation(radians); 803 | } 804 | #endif 805 | } 806 | 807 | - (id)hitTest:(CGPoint)point withEvent:(UIEvent *)event { 808 | id hitView = [super hitTest:point withEvent:event]; 809 | if (hitView != self && ![hitView isKindOfClass:[MBBackgroundView class]]) { 810 | return hitView; 811 | } 812 | return nil; 813 | } 814 | 815 | @end 816 | 817 | 818 | @implementation MBRoundProgressView 819 | 820 | #pragma mark - Lifecycle 821 | 822 | - (id)init { 823 | return [self initWithFrame:CGRectMake(0.f, 0.f, 37.f, 37.f)]; 824 | } 825 | 826 | - (id)initWithFrame:(CGRect)frame { 827 | self = [super initWithFrame:frame]; 828 | if (self) { 829 | self.backgroundColor = [UIColor clearColor]; 830 | self.opaque = NO; 831 | _progress = 0.f; 832 | _annular = NO; 833 | _progressTintColor = [[UIColor alloc] initWithWhite:1.f alpha:1.f]; 834 | _backgroundTintColor = [[UIColor alloc] initWithWhite:1.f alpha:.1f]; 835 | } 836 | return self; 837 | } 838 | 839 | #pragma mark - Layout 840 | 841 | - (CGSize)intrinsicContentSize { 842 | return CGSizeMake(37.f, 37.f); 843 | } 844 | 845 | #pragma mark - Properties 846 | 847 | - (void)setProgress:(float)progress { 848 | if (progress != _progress) { 849 | _progress = progress; 850 | [self setNeedsDisplay]; 851 | } 852 | } 853 | 854 | - (void)setProgressTintColor:(UIColor *)progressTintColor { 855 | NSAssert(progressTintColor, @"The color should not be nil."); 856 | if (progressTintColor != _progressTintColor && ![progressTintColor isEqual:_progressTintColor]) { 857 | _progressTintColor = progressTintColor; 858 | [self setNeedsDisplay]; 859 | } 860 | } 861 | 862 | - (void)setBackgroundTintColor:(UIColor *)backgroundTintColor { 863 | NSAssert(backgroundTintColor, @"The color should not be nil."); 864 | if (backgroundTintColor != _backgroundTintColor && ![backgroundTintColor isEqual:_backgroundTintColor]) { 865 | _backgroundTintColor = backgroundTintColor; 866 | [self setNeedsDisplay]; 867 | } 868 | } 869 | 870 | #pragma mark - Drawing 871 | 872 | - (void)drawRect:(CGRect)rect { 873 | CGContextRef context = UIGraphicsGetCurrentContext(); 874 | 875 | if (_annular) { 876 | // Draw background 877 | CGFloat lineWidth = 2.f; 878 | UIBezierPath *processBackgroundPath = [UIBezierPath bezierPath]; 879 | processBackgroundPath.lineWidth = lineWidth; 880 | processBackgroundPath.lineCapStyle = kCGLineCapButt; 881 | CGPoint center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); 882 | CGFloat radius = (self.bounds.size.width - lineWidth)/2; 883 | CGFloat startAngle = - ((float)M_PI / 2); // 90 degrees 884 | CGFloat endAngle = (2 * (float)M_PI) + startAngle; 885 | [processBackgroundPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; 886 | [_backgroundTintColor set]; 887 | [processBackgroundPath stroke]; 888 | // Draw progress 889 | UIBezierPath *processPath = [UIBezierPath bezierPath]; 890 | processPath.lineCapStyle = kCGLineCapSquare; 891 | processPath.lineWidth = lineWidth; 892 | endAngle = (self.progress * 2 * (float)M_PI) + startAngle; 893 | [processPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; 894 | [_progressTintColor set]; 895 | [processPath stroke]; 896 | } else { 897 | // Draw background 898 | CGFloat lineWidth = 2.f; 899 | CGRect allRect = self.bounds; 900 | CGRect circleRect = CGRectInset(allRect, lineWidth/2.f, lineWidth/2.f); 901 | CGPoint center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); 902 | [_progressTintColor setStroke]; 903 | [_backgroundTintColor setFill]; 904 | CGContextSetLineWidth(context, lineWidth); 905 | CGContextStrokeEllipseInRect(context, circleRect); 906 | // 90 degrees 907 | CGFloat startAngle = - ((float)M_PI / 2.f); 908 | // Draw progress 909 | UIBezierPath *processPath = [UIBezierPath bezierPath]; 910 | processPath.lineCapStyle = kCGLineCapButt; 911 | processPath.lineWidth = lineWidth * 2.f; 912 | CGFloat radius = (CGRectGetWidth(self.bounds) / 2.f) - (processPath.lineWidth / 2.f); 913 | CGFloat endAngle = (self.progress * 2.f * (float)M_PI) + startAngle; 914 | [processPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; 915 | // Ensure that we don't get color overlapping when _progressTintColor alpha < 1.f. 916 | CGContextSetBlendMode(context, kCGBlendModeCopy); 917 | [_progressTintColor set]; 918 | [processPath stroke]; 919 | } 920 | } 921 | 922 | @end 923 | 924 | 925 | @implementation MBBarProgressView 926 | 927 | #pragma mark - Lifecycle 928 | 929 | - (id)init { 930 | return [self initWithFrame:CGRectMake(.0f, .0f, 120.0f, 20.0f)]; 931 | } 932 | 933 | - (id)initWithFrame:(CGRect)frame { 934 | self = [super initWithFrame:frame]; 935 | if (self) { 936 | _progress = 0.f; 937 | _lineColor = [UIColor whiteColor]; 938 | _progressColor = [UIColor whiteColor]; 939 | _progressRemainingColor = [UIColor clearColor]; 940 | self.backgroundColor = [UIColor clearColor]; 941 | self.opaque = NO; 942 | } 943 | return self; 944 | } 945 | 946 | #pragma mark - Layout 947 | 948 | - (CGSize)intrinsicContentSize { 949 | return CGSizeMake(120.f, 10.f); 950 | } 951 | 952 | #pragma mark - Properties 953 | 954 | - (void)setProgress:(float)progress { 955 | if (progress != _progress) { 956 | _progress = progress; 957 | [self setNeedsDisplay]; 958 | } 959 | } 960 | 961 | - (void)setProgressColor:(UIColor *)progressColor { 962 | NSAssert(progressColor, @"The color should not be nil."); 963 | if (progressColor != _progressColor && ![progressColor isEqual:_progressColor]) { 964 | _progressColor = progressColor; 965 | [self setNeedsDisplay]; 966 | } 967 | } 968 | 969 | - (void)setProgressRemainingColor:(UIColor *)progressRemainingColor { 970 | NSAssert(progressRemainingColor, @"The color should not be nil."); 971 | if (progressRemainingColor != _progressRemainingColor && ![progressRemainingColor isEqual:_progressRemainingColor]) { 972 | _progressRemainingColor = progressRemainingColor; 973 | [self setNeedsDisplay]; 974 | } 975 | } 976 | 977 | #pragma mark - Drawing 978 | 979 | - (void)drawRect:(CGRect)rect { 980 | CGContextRef context = UIGraphicsGetCurrentContext(); 981 | 982 | CGContextSetLineWidth(context, 2); 983 | CGContextSetStrokeColorWithColor(context,[_lineColor CGColor]); 984 | CGContextSetFillColorWithColor(context, [_progressRemainingColor CGColor]); 985 | 986 | // Draw background and Border 987 | CGFloat radius = (rect.size.height / 2) - 2; 988 | CGContextMoveToPoint(context, 2, rect.size.height/2); 989 | CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius); 990 | CGContextAddArcToPoint(context, rect.size.width - 2, 2, rect.size.width - 2, rect.size.height / 2, radius); 991 | CGContextAddArcToPoint(context, rect.size.width - 2, rect.size.height - 2, rect.size.width - radius - 2, rect.size.height - 2, radius); 992 | CGContextAddArcToPoint(context, 2, rect.size.height - 2, 2, rect.size.height/2, radius); 993 | CGContextDrawPath(context, kCGPathFillStroke); 994 | 995 | CGContextSetFillColorWithColor(context, [_progressColor CGColor]); 996 | radius = radius - 2; 997 | CGFloat amount = self.progress * rect.size.width; 998 | 999 | // Progress in the middle area 1000 | if (amount >= radius + 4 && amount <= (rect.size.width - radius - 4)) { 1001 | CGContextMoveToPoint(context, 4, rect.size.height/2); 1002 | CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); 1003 | CGContextAddLineToPoint(context, amount, 4); 1004 | CGContextAddLineToPoint(context, amount, radius + 4); 1005 | 1006 | CGContextMoveToPoint(context, 4, rect.size.height/2); 1007 | CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); 1008 | CGContextAddLineToPoint(context, amount, rect.size.height - 4); 1009 | CGContextAddLineToPoint(context, amount, radius + 4); 1010 | 1011 | CGContextFillPath(context); 1012 | } 1013 | 1014 | // Progress in the right arc 1015 | else if (amount > radius + 4) { 1016 | CGFloat x = amount - (rect.size.width - radius - 4); 1017 | 1018 | CGContextMoveToPoint(context, 4, rect.size.height/2); 1019 | CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); 1020 | CGContextAddLineToPoint(context, rect.size.width - radius - 4, 4); 1021 | CGFloat angle = -acos(x/radius); 1022 | if (isnan(angle)) angle = 0; 1023 | CGContextAddArc(context, rect.size.width - radius - 4, rect.size.height/2, radius, M_PI, angle, 0); 1024 | CGContextAddLineToPoint(context, amount, rect.size.height/2); 1025 | 1026 | CGContextMoveToPoint(context, 4, rect.size.height/2); 1027 | CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); 1028 | CGContextAddLineToPoint(context, rect.size.width - radius - 4, rect.size.height - 4); 1029 | angle = acos(x/radius); 1030 | if (isnan(angle)) angle = 0; 1031 | CGContextAddArc(context, rect.size.width - radius - 4, rect.size.height/2, radius, -M_PI, angle, 1); 1032 | CGContextAddLineToPoint(context, amount, rect.size.height/2); 1033 | 1034 | CGContextFillPath(context); 1035 | } 1036 | 1037 | // Progress is in the left arc 1038 | else if (amount < radius + 4 && amount > 0) { 1039 | CGContextMoveToPoint(context, 4, rect.size.height/2); 1040 | CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); 1041 | CGContextAddLineToPoint(context, radius + 4, rect.size.height/2); 1042 | 1043 | CGContextMoveToPoint(context, 4, rect.size.height/2); 1044 | CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); 1045 | CGContextAddLineToPoint(context, radius + 4, rect.size.height/2); 1046 | 1047 | CGContextFillPath(context); 1048 | } 1049 | } 1050 | 1051 | @end 1052 | 1053 | 1054 | @interface MBBackgroundView () 1055 | 1056 | @property UIVisualEffectView *effectView; 1057 | 1058 | @end 1059 | 1060 | 1061 | @implementation MBBackgroundView 1062 | 1063 | #pragma mark - Lifecycle 1064 | 1065 | - (instancetype)initWithFrame:(CGRect)frame { 1066 | if ((self = [super initWithFrame:frame])) { 1067 | _style = MBProgressHUDBackgroundStyleBlur; 1068 | if (@available(iOS 13.0, *)) { 1069 | #if TARGET_OS_TV 1070 | _blurEffectStyle = UIBlurEffectStyleRegular; 1071 | #else 1072 | _blurEffectStyle = UIBlurEffectStyleSystemThickMaterial; 1073 | #endif 1074 | // Leaving the color unassigned yields best results. 1075 | } else { 1076 | _blurEffectStyle = UIBlurEffectStyleLight; 1077 | _color = [UIColor colorWithWhite:0.8f alpha:0.6f]; 1078 | } 1079 | 1080 | self.clipsToBounds = YES; 1081 | 1082 | [self updateForBackgroundStyle]; 1083 | } 1084 | return self; 1085 | } 1086 | 1087 | #pragma mark - Layout 1088 | 1089 | - (CGSize)intrinsicContentSize { 1090 | // Smallest size possible. Content pushes against this. 1091 | return CGSizeZero; 1092 | } 1093 | 1094 | #pragma mark - Appearance 1095 | 1096 | - (void)setStyle:(MBProgressHUDBackgroundStyle)style { 1097 | if (_style != style) { 1098 | _style = style; 1099 | [self updateForBackgroundStyle]; 1100 | } 1101 | } 1102 | 1103 | - (void)setColor:(UIColor *)color { 1104 | NSAssert(color, @"The color should not be nil."); 1105 | if (color != _color && ![color isEqual:_color]) { 1106 | _color = color; 1107 | [self updateViewsForColor:color]; 1108 | } 1109 | } 1110 | 1111 | - (void)setBlurEffectStyle:(UIBlurEffectStyle)blurEffectStyle { 1112 | if (_blurEffectStyle == blurEffectStyle) { 1113 | return; 1114 | } 1115 | 1116 | _blurEffectStyle = blurEffectStyle; 1117 | 1118 | [self updateForBackgroundStyle]; 1119 | } 1120 | 1121 | /////////////////////////////////////////////////////////////////////////////////////////// 1122 | #pragma mark - Views 1123 | 1124 | - (void)updateForBackgroundStyle { 1125 | [self.effectView removeFromSuperview]; 1126 | self.effectView = nil; 1127 | 1128 | MBProgressHUDBackgroundStyle style = self.style; 1129 | if (style == MBProgressHUDBackgroundStyleBlur) { 1130 | UIBlurEffect *effect = [UIBlurEffect effectWithStyle:self.blurEffectStyle]; 1131 | UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect]; 1132 | [self insertSubview:effectView atIndex:0]; 1133 | effectView.frame = self.bounds; 1134 | effectView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 1135 | self.backgroundColor = self.color; 1136 | self.layer.allowsGroupOpacity = NO; 1137 | self.effectView = effectView; 1138 | } else { 1139 | self.backgroundColor = self.color; 1140 | } 1141 | } 1142 | 1143 | - (void)updateViewsForColor:(UIColor *)color { 1144 | if (self.style == MBProgressHUDBackgroundStyleBlur) { 1145 | self.backgroundColor = self.color; 1146 | } else { 1147 | self.backgroundColor = self.color; 1148 | } 1149 | } 1150 | 1151 | @end 1152 | 1153 | 1154 | @implementation MBProgressHUDRoundedButton 1155 | 1156 | #pragma mark - Lifecycle 1157 | 1158 | - (instancetype)initWithFrame:(CGRect)frame { 1159 | self = [super initWithFrame:frame]; 1160 | if (self) { 1161 | CALayer *layer = self.layer; 1162 | layer.borderWidth = 1.f; 1163 | } 1164 | return self; 1165 | } 1166 | 1167 | #pragma mark - Layout 1168 | 1169 | - (void)layoutSubviews { 1170 | [super layoutSubviews]; 1171 | // Fully rounded corners 1172 | CGFloat height = CGRectGetHeight(self.bounds); 1173 | self.layer.cornerRadius = ceil(height / 2.f); 1174 | } 1175 | 1176 | - (CGSize)intrinsicContentSize { 1177 | // Only show if we have associated control events and a title 1178 | if ((self.allControlEvents == 0) || ([self titleForState:UIControlStateNormal].length == 0)) 1179 | return CGSizeZero; 1180 | CGSize size = [super intrinsicContentSize]; 1181 | // Add some side padding 1182 | size.width += 20.f; 1183 | return size; 1184 | } 1185 | 1186 | #pragma mark - Color 1187 | 1188 | - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state { 1189 | [super setTitleColor:color forState:state]; 1190 | // Update related colors 1191 | [self setHighlighted:self.highlighted]; 1192 | self.layer.borderColor = color.CGColor; 1193 | } 1194 | 1195 | - (void)setHighlighted:(BOOL)highlighted { 1196 | [super setHighlighted:highlighted]; 1197 | UIColor *baseColor = [self titleColorForState:UIControlStateSelected]; 1198 | self.backgroundColor = highlighted ? [baseColor colorWithAlphaComponent:0.1f] : [UIColor clearColor]; 1199 | } 1200 | 1201 | @end 1202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(ROOTLESS),1) 2 | THEOS_PACKAGE_SCHEME=rootless 3 | endif 4 | 5 | export ARCHS = arm64 6 | TARGET := iphone:clang:16.5:13.0 7 | INSTALL_TARGET_PROCESSES = YouTube 8 | 9 | include $(THEOS)/makefiles/common.mk 10 | 11 | TWEAK_NAME = iSponsorBlock 12 | 13 | iSponsorBlock_FILES = iSponsorBlock.xm $(wildcard *.m) 14 | iSponsorBlock_LIBRARIES = colorpicker 15 | iSponsorBlock_CFLAGS = -fobjc-arc -Wno-deprecated-declarations -Wno-module-import-in-extern-c -Wno-unknown-warning-option -Wno-vla-cxx-extension -Wno-vla-extension 16 | 17 | include $(THEOS_MAKE_PATH)/tweak.mk 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iSponsorBlock 2 | A jailbreak tweak that implements the SponsorBlock API to skip sponsorships in YouTube videos. 3 | 4 | More info about SponsorBlock and the API used can be found [here](https://sponsor.ajay.app). 5 | 6 | This tweak has been tested on the latest YouTube version (18.20.3) and supports, at least, down to version 17.30.1. 7 | 8 | # Installation 9 | 10 | Add the following repository: https://repo.icrazeios.com 11 | 12 | # Customization 13 | To access this tweaks settings open the YouTube app, and there should be a button in the top right, like in this image: https://imgur.com/lLpfXue. 14 | -------------------------------------------------------------------------------- /SponsorBlockRequest.m: -------------------------------------------------------------------------------- 1 | #import "Headers/SponsorBlockRequest.h" 2 | #import "Headers/Localization.h" 3 | 4 | @implementation SponsorBlockRequest 5 | + (void)getSponsorTimes:(NSString *)videoID completionTarget:(id)target completionSelector:(SEL)sel apiInstance:(NSString *)apiInstance { 6 | __block NSMutableArray *skipSegments = [NSMutableArray array]; 7 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; 8 | NSString *categories = @"%5B%22sponsor%22%2C%22intro%22%2C%22outro%22%2C%22interaction%22%2C%22selfpromo%22%2C%22music_offtopic%22%2C%22preview%22%2C%22poi_highlight%22%2C%22filler%22%5D"; 9 | 10 | //NSString *categories = @"[%22sponsor%22,%20%22intro%22,%20%22outro%22,%20%22interaction%22,%20%22selfpromo%22,%20%22music_offtopic%22,%20%22preview%22,%20%22filler%22]"; 11 | 12 | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/skipSegments?videoID=%@&categories=%@", apiInstance, videoID, categories]]]; 13 | request.HTTPMethod = @"GET"; 14 | NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { 15 | if (data != nil && error == nil) { 16 | NSArray *jsonData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; 17 | NSMutableArray *segments = [NSMutableArray array]; 18 | for (NSDictionary *dict in jsonData) { 19 | SponsorSegment *segment = [[SponsorSegment alloc] initWithStartTime:[[dict objectForKey:@"segment"][0] floatValue] endTime:[[dict objectForKey:@"segment"][1] floatValue] category:(NSString *)[dict objectForKey:@"category"] UUID:(NSString *)[dict objectForKey:@"UUID"]]; 20 | [segments addObject:segment]; 21 | } 22 | skipSegments = [segments sortedArrayUsingComparator:^NSComparisonResult(SponsorSegment *a, SponsorSegment *b) { 23 | NSNumber *first = @(a.startTime); 24 | NSNumber *second = @(b.startTime); 25 | return [first compare:second]; 26 | }].mutableCopy; 27 | NSMutableArray *seekBarSegments = skipSegments.mutableCopy; 28 | for (SponsorSegment *segment in skipSegments.copy) { 29 | NSInteger setting = [[kCategorySettings objectForKey:segment.category] intValue]; 30 | switch (setting) { 31 | case 0: 32 | [skipSegments removeObject:segment]; 33 | [seekBarSegments removeObject:segment]; 34 | break; 35 | case 2: 36 | [skipSegments removeObject:segment]; 37 | break; 38 | //only leaves the object in seekBarSegments so it appears in the seek bar but doesn't get skipped 39 | default: 40 | break; 41 | } 42 | if (segment.endTime - segment.startTime < kMinimumDuration) { 43 | [skipSegments removeObject:segment]; 44 | [seekBarSegments removeObject:segment]; 45 | } 46 | 47 | } 48 | [target performSelectorOnMainThread:sel withObject:skipSegments waitUntilDone:NO]; 49 | 50 | if ([target isKindOfClass:objc_getClass("YTPlayerViewController")]) { 51 | YTPlayerViewController *playerViewController = (YTPlayerViewController *)target; 52 | YTPlayerView *playerView = (YTPlayerView *)playerViewController.view; 53 | YTMainAppVideoPlayerOverlayView *overlayView = (YTMainAppVideoPlayerOverlayView *)playerView.overlayView; 54 | if ([overlayView isKindOfClass:objc_getClass("YTMainAppVideoPlayerOverlayView")]) { 55 | id playerBar = overlayView.playerBar.playerBar; 56 | if (playerBar) { 57 | if ([playerBar isKindOfClass:objc_getClass("YTModularPlayerBarController")]) { 58 | YTModularPlayerBarView *view = ((YTModularPlayerBarController *)playerBar).view; 59 | [view performSelectorOnMainThread:@selector(setSkipSegments:) withObject:seekBarSegments waitUntilDone:NO]; 60 | } else { 61 | [playerBar performSelectorOnMainThread:@selector(setSkipSegments:) withObject:seekBarSegments waitUntilDone:NO]; 62 | } 63 | } 64 | else { 65 | [overlayView.playerBar.playerBar performSelectorOnMainThread:@selector(setSkipSegments:) withObject:seekBarSegments waitUntilDone:NO]; 66 | } 67 | } 68 | } 69 | } 70 | }]; 71 | [dataTask resume]; 72 | } 73 | + (void)postSponsorTimes:(NSString *)videoID sponsorSegments:(NSArray *)segments userID:(NSString *)userID withViewController:(UIViewController *)viewController { 74 | for (SponsorSegment *segment in segments) { 75 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; 76 | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://sponsor.ajay.app/api/skipSegments?videoID=%@&startTime=%f&endTime=%f&category=%@&userID=%@", videoID, segment.startTime, segment.endTime, segment.category, userID]]]; 77 | request.HTTPMethod = @"POST"; 78 | NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { 79 | NSHTTPURLResponse *URLResponse = (NSHTTPURLResponse *)response; 80 | if (URLResponse.statusCode != 200) { 81 | dispatch_async(dispatch_get_main_queue(), ^{ 82 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOC(@"Error") message:[NSString stringWithFormat:@"%@: %ld %@", LOC(@"ErrorCode"), URLResponse.statusCode, [NSHTTPURLResponse localizedStringForStatusCode:URLResponse.statusCode]] preferredStyle:UIAlertControllerStyleAlert]; 83 | UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:LOC(@"OK") style:UIAlertActionStyleDefault 84 | handler:^(UIAlertAction * action) {}]; 85 | [alert addAction:defaultAction]; 86 | [viewController presentViewController:alert animated:YES completion:nil]; 87 | }); 88 | return; 89 | } 90 | else { 91 | dispatch_async(dispatch_get_main_queue(), ^{ 92 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOC(@"Success") message:LOC(@"SuccessfullySubmittedSegments") preferredStyle:UIAlertControllerStyleAlert]; 93 | UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:LOC(@"OK") style:UIAlertActionStyleDefault 94 | handler:^(UIAlertAction * action) {}]; 95 | [alert addAction:defaultAction]; 96 | [viewController presentViewController:alert animated:YES completion:nil]; 97 | }); 98 | } 99 | }]; 100 | [dataTask resume]; 101 | } 102 | } 103 | + (void)normalVoteForSegment:(SponsorSegment *)segment userID:(NSString *)userID type:(BOOL)type withViewController:(UIViewController *)viewController { 104 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; 105 | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://sponsor.ajay.app/api/voteOnSponsorTime?UUID=%@&userID=%@&type=%d", segment.UUID, userID, type]]]; 106 | request.HTTPMethod = @"POST"; 107 | NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { 108 | NSHTTPURLResponse *URLResponse = (NSHTTPURLResponse *)response; 109 | NSString *title; 110 | CGFloat delay; 111 | if (URLResponse.statusCode != 200) { 112 | title = [NSString stringWithFormat:@"%@: (%ld %@)", LOC(@"ErrorVoting"), URLResponse.statusCode, [NSHTTPURLResponse localizedStringForStatusCode:URLResponse.statusCode]]; 113 | delay = 3.0f; 114 | } 115 | else { 116 | title = LOC(@"SuccessfullyVoted"); 117 | delay = 1.0f; 118 | } 119 | dispatch_async(dispatch_get_main_queue(), ^{ 120 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:viewController.view animated:YES]; 121 | hud.mode = MBProgressHUDModeText; 122 | hud.label.text = title; 123 | hud.offset = CGPointMake(0.f, 50); 124 | [hud hideAnimated:YES afterDelay:delay]; 125 | }); 126 | }]; 127 | [dataTask resume]; 128 | } 129 | + (void)categoryVoteForSegment:(SponsorSegment *)segment userID:(NSString *)userID category:(NSString *)category withViewController:(UIViewController *)viewController { 130 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; 131 | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://sponsor.ajay.app/api/voteOnSponsorTime?UUID=%@&userID=%@&category=%@", segment.UUID, userID, category]]]; 132 | request.HTTPMethod = @"POST"; 133 | NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { 134 | NSHTTPURLResponse *URLResponse = (NSHTTPURLResponse *)response; 135 | NSString *title; 136 | CGFloat delay; 137 | if (URLResponse.statusCode != 200) { 138 | title = [NSString stringWithFormat:@"%@: (%ld %@)", LOC(@"ErrorVoting"), URLResponse.statusCode, [NSHTTPURLResponse localizedStringForStatusCode:URLResponse.statusCode]]; 139 | delay = 3.0f; 140 | } 141 | else { 142 | title = LOC(@"SuccessfullyVoted"); 143 | delay = 1.0f; 144 | } 145 | dispatch_async(dispatch_get_main_queue(), ^{ 146 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:viewController.view animated:YES]; 147 | hud.mode = MBProgressHUDModeText; 148 | hud.label.text = title; 149 | hud.offset = CGPointMake(0.f, 50); 150 | [hud hideAnimated:YES afterDelay:delay]; 151 | }); 152 | }]; 153 | [dataTask resume]; 154 | } 155 | + (void)viewedVideoSponsorTime:(SponsorSegment *)segment { 156 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; 157 | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://sponsor.ajay.app/api/viewedVideoSponsorTime?UUID=%@", segment.UUID]]]; 158 | request.HTTPMethod = @"POST"; 159 | NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { 160 | }]; 161 | [dataTask resume]; 162 | } 163 | @end 164 | -------------------------------------------------------------------------------- /SponsorBlockSettingsController.m: -------------------------------------------------------------------------------- 1 | #import "Headers/SponsorBlockSettingsController.h" 2 | #import "Headers/Localization.h" 3 | 4 | @implementation SponsorBlockTableCell 5 | - (void)colorPicker:(id)colorPicker didSelectColor:(UIColor *)color { 6 | self.colorWell.color = color; 7 | NSString *hexString = hexFromUIColor(color); 8 | 9 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 10 | NSString *documentsDirectory = [paths objectAtIndex:0]; 11 | NSString *settingsPath = [documentsDirectory stringByAppendingPathComponent:@"iSponsorBlock.plist"]; 12 | NSMutableDictionary *settings = [NSMutableDictionary dictionary]; 13 | [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:settingsPath]]; 14 | NSDictionary *categorySettings = [settings objectForKey:@"categorySettings"]; 15 | 16 | [categorySettings setValue:hexString forKey:[NSString stringWithFormat:@"%@Color", self.category]]; 17 | [settings setValue:categorySettings forKey:@"categorySettings"]; 18 | [settings writeToURL:[NSURL fileURLWithPath:settingsPath isDirectory:NO] error:nil]; 19 | CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.galacticdev.isponsorblockprefs.changed"), NULL, NULL, YES); 20 | } 21 | 22 | - (void)presentColorPicker:(UITableViewCell *)sender { 23 | HBColorPickerViewController *viewController = [[objc_getClass("HBColorPickerViewController") alloc] init]; 24 | viewController.delegate = self; 25 | viewController.popoverPresentationController.sourceView = self; 26 | 27 | HBColorPickerConfiguration *configuration = [[objc_getClass("HBColorPickerConfiguration") alloc] initWithColor:self.colorWell.color]; 28 | configuration.supportsAlpha = NO; 29 | viewController.configuration = configuration; 30 | 31 | UIViewController *rootViewController = self._viewControllerForAncestor; 32 | [rootViewController presentViewController:viewController animated:YES completion:nil]; 33 | 34 | //fixes the bottom of the color picker from getting cut off 35 | viewController.view.frame = CGRectMake(0,-50, viewController.view.frame.size.width, viewController.view.frame.size.height); 36 | } 37 | @end 38 | 39 | @implementation SponsorBlockSettingsController 40 | - (void)viewDidLoad { 41 | [super viewDidLoad]; 42 | 43 | UIBarButtonItem *dismissButton; 44 | 45 | dismissButton = [[UIBarButtonItem alloc] initWithImage:[UIImage systemImageNamed:@"xmark"] 46 | style:UIBarButtonItemStylePlain 47 | target:self 48 | action:@selector(dismissButtonTapped:)]; 49 | 50 | dismissButton.tintColor = [UIColor labelColor]; 51 | self.navigationItem.leftBarButtonItem = dismissButton; 52 | 53 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 54 | NSString *documentsDirectory = [paths objectAtIndex:0]; 55 | self.settingsPath = [documentsDirectory stringByAppendingPathComponent:@"iSponsorBlock.plist"]; 56 | self.settings = [NSMutableDictionary dictionary]; 57 | [self.settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:self.settingsPath]]; 58 | 59 | self.view.backgroundColor = UIColor.systemBackgroundColor; 60 | 61 | //detects if device is an se gen 1 or not, crude fix for text getting cut off 62 | if ([UIScreen mainScreen].bounds.size.width > 320) { 63 | self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleInsetGrouped]; 64 | } 65 | else { 66 | self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped]; 67 | } 68 | 69 | [self.view addSubview:self.tableView]; 70 | self.tableView.translatesAutoresizingMaskIntoConstraints = NO; 71 | [self.tableView.heightAnchor constraintEqualToAnchor:self.view.heightAnchor].active = YES; 72 | [self.tableView.widthAnchor constraintEqualToAnchor:self.view.widthAnchor].active = YES; 73 | self.tableView.delegate = self; 74 | self.tableView.dataSource = self; 75 | 76 | NSBundle *tweakBundle = iSponsorBlockBundle(); 77 | UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:[tweakBundle pathForResource:@"LogoSponsorBlocker128px" ofType:@"png"]]]; 78 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)]; 79 | label.text = @"iSponsorBlock"; 80 | label.font = [UIFont boldSystemFontOfSize:48]; 81 | self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0,0,0,200)]; 82 | [self.tableView.tableHeaderView addSubview:imageView]; 83 | [self.tableView.tableHeaderView addSubview:label]; 84 | 85 | self.tweakTitle = label.text; 86 | 87 | imageView.translatesAutoresizingMaskIntoConstraints = NO; 88 | label.translatesAutoresizingMaskIntoConstraints = NO; 89 | [imageView.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor].active = YES; 90 | [imageView.topAnchor constraintEqualToAnchor:self.tableView.tableHeaderView.topAnchor constant:5].active = YES; 91 | [label.centerXAnchor constraintEqualToAnchor:imageView.centerXAnchor].active = YES; 92 | [label.topAnchor constraintEqualToAnchor:imageView.bottomAnchor constant:5].active = YES; 93 | 94 | //for dismissing num pad when tapping anywhere on the string 95 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(endEditing:)]; 96 | tap.cancelsTouchesInView = NO; 97 | [self.view addGestureRecognizer:tap]; 98 | 99 | self.sectionTitles = @[LOC(@"Sponsor"), LOC(@"Intermission/IntroAnimation"), LOC(@"Endcards/Credits"), LOC(@"InteractionReminder"), LOC(@"Unpaid/SelfPromotion"), LOC(@"Non-MusicSection"), LOC(@"Preview"), LOC(@"SponsorBlockUserID"), LOC(@"SponsorBlockAPIInstance")]; 100 | } 101 | 102 | //Add iSponsorBlock text to Navbar label if header text out of screen 103 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 104 | CGRect labelCellRect = [self.tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; 105 | CGRect visibleRect = CGRectMake(self.tableView.contentOffset.x, 106 | self.tableView.contentOffset.y + self.navigationController.navigationBar.frame.size.height, 107 | self.tableView.bounds.size.width, 108 | self.tableView.bounds.size.height - self.navigationController.navigationBar.frame.size.height); 109 | 110 | if (!CGRectContainsRect(visibleRect, labelCellRect)) { 111 | self.title = self.tweakTitle; 112 | [UIView animateWithDuration:0.3 animations:^{ 113 | self.navigationItem.titleView.alpha = 1.0; 114 | }]; 115 | } else { 116 | self.title = nil; 117 | [UIView animateWithDuration:0.3 animations:^{ 118 | self.navigationItem.titleView.alpha = 0.0; 119 | }]; 120 | } 121 | } 122 | 123 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 124 | return 19; 125 | } 126 | 127 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 128 | if (section == 0) return 1; 129 | else if (section <= 7 || section == 18) return 2; 130 | return 1; 131 | } 132 | 133 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 134 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SponsorBlockCell"]; 135 | if (!cell) { 136 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SponsorBlocKCell"]; 137 | } 138 | 139 | if (indexPath.section == 0) { 140 | cell.textLabel.text = LOC(@"Enabled"); 141 | UISwitch *enabledSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0,0,51,31)]; 142 | cell.accessoryView = enabledSwitch; 143 | [enabledSwitch addTarget:self action:@selector(enabledSwitchToggled:) forControlEvents:UIControlEventValueChanged]; 144 | if ([self.settings valueForKey:@"enabled"]) { 145 | [enabledSwitch setOn:[[self.settings valueForKey:@"enabled"] boolValue] animated:NO]; 146 | } 147 | else { 148 | [enabledSwitch setOn:YES animated:NO]; 149 | [self enabledSwitchToggled:enabledSwitch]; 150 | } 151 | return cell; 152 | } 153 | 154 | if (indexPath.section <= 7) { 155 | SponsorBlockTableCell *tableCell = [[SponsorBlockTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SponsorBlockCell2"]; 156 | NSDictionary *categorySettings = [self.settings objectForKey:@"categorySettings"]; 157 | UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[LOC(@"Disable"), LOC(@"AutoSkip"), LOC(@"ShowInSeekBar"), LOC(@"ManualSkip")]]; 158 | 159 | //make it so "Show in Seek Bar" text won't be cut off on certain devices 160 | NSMutableArray *segments = [segmentedControl valueForKey:@"_segments"]; 161 | UISegment *segment = segments[2]; 162 | UILabel *label = [segment valueForKey:@"_info"]; 163 | label.adjustsFontSizeToFitWidth = YES; 164 | 165 | switch (indexPath.section) { 166 | case 1: 167 | segmentedControl.selectedSegmentIndex = [[categorySettings objectForKey:@"sponsor"] intValue]; 168 | tableCell.category = @"sponsor"; 169 | break; 170 | case 2: 171 | segmentedControl.selectedSegmentIndex = [[categorySettings objectForKey:@"intro"] intValue]; 172 | tableCell.category = @"intro"; 173 | break; 174 | case 3: 175 | segmentedControl.selectedSegmentIndex = [[categorySettings objectForKey:@"outro"] intValue]; 176 | tableCell.category = @"outro"; 177 | break; 178 | case 4: 179 | segmentedControl.selectedSegmentIndex = [[categorySettings objectForKey:@"interaction"] intValue]; 180 | tableCell.category = @"interaction"; 181 | break; 182 | case 5: 183 | segmentedControl.selectedSegmentIndex = [[categorySettings objectForKey:@"selfpromo"] intValue]; 184 | tableCell.category = @"selfpromo"; 185 | break; 186 | case 6: 187 | segmentedControl.selectedSegmentIndex = [[categorySettings objectForKey:@"music_offtopic"] intValue]; 188 | tableCell.category = @"music_offtopic"; 189 | break; 190 | case 7: 191 | segmentedControl.selectedSegmentIndex = [[categorySettings objectForKey:@"preview"] intValue]; 192 | tableCell.category = @"preview"; 193 | break; 194 | 195 | default: 196 | break; 197 | } 198 | if (indexPath.row == 0) { 199 | [segmentedControl addTarget:self action:@selector(categorySegmentSelected:) forControlEvents:UIControlEventValueChanged]; 200 | segmentedControl.apportionsSegmentWidthsByContent = YES; 201 | [tableCell.contentView addSubview:segmentedControl]; 202 | segmentedControl.translatesAutoresizingMaskIntoConstraints = NO; 203 | [segmentedControl.centerYAnchor constraintEqualToAnchor:tableCell.contentView.centerYAnchor].active = YES; 204 | [segmentedControl.widthAnchor constraintEqualToAnchor:tableCell.contentView.widthAnchor].active = YES; 205 | } 206 | else { 207 | tableCell.textLabel.text = LOC(@"SetColorToShowInSeekBar"); 208 | tableCell.textLabel.adjustsFontSizeToFitWidth = YES; 209 | HBColorWell *colorWell = [[objc_getClass("HBColorWell") alloc] initWithFrame:CGRectMake(0,0,32,32)]; 210 | [colorWell addTarget:tableCell action:@selector(presentColorPicker:) forControlEvents:UIControlEventTouchUpInside]; 211 | UIColor *color = colorWithHexString([categorySettings objectForKey:[NSString stringWithFormat:@"%@Color", tableCell.category]]); 212 | colorWell.color = color; 213 | tableCell.accessoryView = colorWell; 214 | tableCell.colorWell = colorWell; 215 | } 216 | return tableCell; 217 | } 218 | if (indexPath.section == 8) { 219 | UITableViewCell *textCell = [[UITableViewCell alloc] initWithStyle:1000 reuseIdentifier:@"SponsorBlockTextCell"]; 220 | textCell.textLabel.text = LOC(@"UserID"); 221 | textCell.textLabel.adjustsFontSizeToFitWidth = YES; 222 | [textCell editableTextField].text = [self.settings valueForKey:@"userID"]; 223 | [textCell editableTextField].delegate = self; 224 | return textCell; 225 | } 226 | if (indexPath.section == 9) { 227 | UITableViewCell *textCell = [[UITableViewCell alloc] initWithStyle:1000 reuseIdentifier:@"SponsorBlockTextCell"]; 228 | textCell.textLabel.text = LOC(@"API_URL"); 229 | textCell.textLabel.adjustsFontSizeToFitWidth = YES; 230 | [textCell editableTextField].text = [self.settings valueForKey:@"apiInstance"]; 231 | [textCell editableTextField].delegate = self; 232 | return textCell; 233 | } 234 | if (indexPath.section == 10) { 235 | UITableViewCell *textCell = [[UITableViewCell alloc] initWithStyle:1000 reuseIdentifier:@"SponsorBlockTextCell"]; 236 | textCell.textLabel.text = LOC(@"MinimumSegmentDuration"); 237 | textCell.textLabel.adjustsFontSizeToFitWidth = YES; 238 | [textCell editableTextField].text = [NSString stringWithFormat:@"%.1f", [[self.settings valueForKey:@"minimumDuration"] floatValue]]; 239 | [textCell editableTextField].keyboardType = UIKeyboardTypeDecimalPad; 240 | [textCell editableTextField].delegate = self; 241 | return textCell; 242 | } 243 | if (indexPath.section == 11) { 244 | UITableViewCell *textCell = [[UITableViewCell alloc] initWithStyle:1000 reuseIdentifier:@"SponsorBlockTextCell"]; 245 | textCell.textLabel.text = LOC(@"HowLongNoticeWillAppear"); 246 | textCell.textLabel.adjustsFontSizeToFitWidth = YES; 247 | [textCell editableTextField].text = [NSString stringWithFormat:@"%.1f", [[self.settings valueForKey:@"skipNoticeDuration"] floatValue]]; 248 | [textCell editableTextField].keyboardType = UIKeyboardTypeDecimalPad; 249 | [textCell editableTextField].delegate = self; 250 | return textCell; 251 | } 252 | if (indexPath.section >= 12 && indexPath.section < 18) { 253 | NSArray *titles = @[LOC(@"ShowSkipNotice"), LOC(@"ShowButtonsInPlayer"), LOC(@"HideStartEndButtonInPlayer"), LOC(@"ShowModifiedTime"), LOC(@"AudioNotificationOnSkip"), LOC(@"EnableSkipCountTracking")]; 254 | NSArray *titlesNames = @[@"showSkipNotice", @"showButtonsInPlayer", @"hideStartEndButtonInPlayer", @"showModifiedTime", @"skipAudioNotification", @"enableSkipCountTracking"]; 255 | UITableViewCell *tableCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SponsorBlockCell3"]; 256 | 257 | tableCell.textLabel.text = titles[indexPath.section-12]; 258 | tableCell.textLabel.adjustsFontSizeToFitWidth = YES; 259 | 260 | UISwitch *toggleSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0,0,51,31)]; 261 | tableCell.accessoryView = toggleSwitch; 262 | [toggleSwitch addTarget:self action:@selector(switchToggled:) forControlEvents:UIControlEventValueChanged]; 263 | if ([self.settings valueForKey:titlesNames[indexPath.section-12]]) { 264 | [toggleSwitch setOn:[[self.settings valueForKey:titlesNames[indexPath.section-12]] boolValue] animated:NO]; 265 | } else { 266 | [toggleSwitch setOn:YES animated:NO]; 267 | [self switchToggled:toggleSwitch]; 268 | } 269 | return tableCell; 270 | } 271 | if (indexPath.section == 18) { 272 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SponsorBlockDonationCell"]; 273 | cell.textLabel.text = indexPath.row == 0 ? LOC(@"DonateOnVenmo") : LOC(@"DonateOnPayPal"); 274 | cell.imageView.image = [UIImage systemImageNamed:@"dollarsign.circle.fill"]; 275 | return cell; 276 | } 277 | return nil; 278 | } 279 | 280 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 281 | if (section == 0) return nil; 282 | if (section <= 9) return self.sectionTitles[section-1]; 283 | return nil; 284 | } 285 | 286 | - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { 287 | if (section == 0) return LOC(@"RestartFooter"); 288 | if (section == 8) return LOC(@"UserIDFooter"); 289 | if (section == 9) return LOC(@"APIFooter"); 290 | if (section == 16) return LOC(@"AudioFooter"); 291 | return nil; 292 | } 293 | 294 | //To allow highlights only for certain sections 295 | - (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath { 296 | if (indexPath.section == 18) { 297 | return YES; 298 | } else { 299 | return NO; 300 | } 301 | } 302 | 303 | - (void)dismissButtonTapped:(id)sender { 304 | [self dismissViewControllerAnimated:YES completion:nil]; 305 | } 306 | 307 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 308 | if (indexPath.section == 18) { 309 | if (indexPath.row == 0) { 310 | if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"venmo://"]]) { 311 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"venmo://venmo.com/code?user_id=3178620965093376215"] options:@{} completionHandler:nil]; 312 | } else { 313 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://venmo.com/code?user_id=3178620965093376215"] options:@{} completionHandler:nil]; 314 | } 315 | 316 | } else { 317 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://paypal.me/DBrett684"] options:@{} completionHandler:nil]; 318 | } 319 | } 320 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; //To prevent highlight sticking after pressing on buttons 321 | } 322 | 323 | - (void)enabledSwitchToggled:(UISwitch *)sender { 324 | [self.settings setValue:@(sender.on) forKey:@"enabled"]; 325 | [self writeSettings]; 326 | } 327 | 328 | - (void)switchToggled:(UISwitch *)sender { 329 | UITableViewCell *cell = (UITableViewCell *)sender.superview; 330 | NSArray *titlesNames = @[@"showSkipNotice", @"showButtonsInPlayer", @"hideStartEndButtonInPlayer", @"showModifiedTime", @"skipAudioNotification", @"enableSkipCountTracking"]; 331 | NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; 332 | [self.settings setValue:@(sender.on) forKey:titlesNames[indexPath.section-11]]; 333 | [self writeSettings]; 334 | } 335 | 336 | - (void)categorySegmentSelected:(UISegmentedControl *)segmentedControl { 337 | NSMutableDictionary *categorySettings = [self.settings valueForKey:@"categorySettings"]; 338 | [categorySettings setValue:@(segmentedControl.selectedSegmentIndex) forKey:[(SponsorBlockTableCell *)segmentedControl.superview.superview category]]; 339 | 340 | [self.settings setValue:categorySettings forKey:@"categorySettings"]; 341 | [self writeSettings]; 342 | } 343 | 344 | - (void)textFieldDidEndEditing:(UITextField *)textField { 345 | UITableViewCell *cell = (UITableViewCell *)textField.superview.superview; 346 | NSNumberFormatter *f = [[NSNumberFormatter alloc] init]; 347 | f.numberStyle = NSNumberFormatterDecimalStyle; 348 | 349 | NSString *minimumDurationTitle = LOC(@"MinimumSegmentDuration"); 350 | NSString *skipNoticeDurationTitle = LOC(@"HowLongNoticeWillAppear"); 351 | NSString *userIDTitle = LOC(@"UserID"); 352 | NSString *apiURLTitle = LOC(@"API_URL"); 353 | 354 | if ([cell.textLabel.text isEqualToString:minimumDurationTitle]) { 355 | [self.settings setValue:[f numberFromString:textField.text] forKey:@"minimumDuration"]; 356 | } else if ([cell.textLabel.text isEqualToString:skipNoticeDurationTitle]) { 357 | [self.settings setValue:[f numberFromString:textField.text] forKey:@"skipNoticeDuration"]; 358 | } else if ([cell.textLabel.text isEqualToString:userIDTitle]) { 359 | [self.settings setValue:textField.text forKey:@"userID"]; 360 | } else if ([cell.textLabel.text isEqualToString:apiURLTitle]) { 361 | [self.settings setValue:textField.text forKey:@"apiInstance"]; 362 | } 363 | [self writeSettings]; 364 | } 365 | 366 | - (void)writeSettings { 367 | [self.settings writeToURL:[NSURL fileURLWithPath:self.settingsPath isDirectory:NO] error:nil]; 368 | CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.galacticdev.isponsorblockprefs.changed"), NULL, NULL, YES); 369 | } 370 | @end 371 | -------------------------------------------------------------------------------- /SponsorBlockViewController.m: -------------------------------------------------------------------------------- 1 | #import "Headers/SponsorBlockViewController.h" 2 | #import "Headers/Localization.h" 3 | 4 | @implementation SponsorBlockViewController 5 | 6 | - (void)viewDidLoad { 7 | [super viewDidLoad]; 8 | self.view.backgroundColor = [UIColor systemBackgroundColor]; 9 | [self addChildViewController:self.playerViewController]; 10 | [self.view addSubview:self.playerViewController.view]; 11 | [self setupViews]; 12 | } 13 | 14 | - (NSArray *)skipSegments { 15 | // I'm using the playerBar skipSegments instead of the playerViewController ones because of the show in seek bar option 16 | YTPlayerView *playerView = (YTPlayerView *)self.playerViewController.view; 17 | YTMainAppVideoPlayerOverlayView *overlayView = (YTMainAppVideoPlayerOverlayView *)playerView.overlayView; 18 | if ([overlayView isKindOfClass:NSClassFromString(@"YTMainAppVideoPlayerOverlayView")]) { 19 | id object = [overlayView.playerBar respondsToSelector:@selector(modularPlayerBar)] ? overlayView.playerBar.modularPlayerBar : overlayView.playerBar.segmentablePlayerBar; 20 | if ([object isKindOfClass:NSClassFromString(@"YTSegmentableInlinePlayerBarView")]) 21 | return ((YTSegmentableInlinePlayerBarView *)object).skipSegments; 22 | if ([object isKindOfClass:NSClassFromString(@"YTModularPlayerBarController")]) { 23 | YTModularPlayerBarView *view = ((YTModularPlayerBarController *)object).view; 24 | if ([view isKindOfClass:NSClassFromString(@"YTModularPlayerBarView")]) 25 | return view.skipSegments; 26 | } 27 | } 28 | return nil; 29 | } 30 | 31 | - (void)setupViews { 32 | [self.segmentsInDatabaseLabel removeFromSuperview]; 33 | [self.userSegmentsLabel removeFromSuperview]; 34 | [self.submitSegmentsButton removeFromSuperview]; 35 | [self.whitelistChannelLabel removeFromSuperview]; 36 | 37 | self.sponsorSegmentViews = [NSMutableArray array]; 38 | self.userSponsorSegmentViews = [NSMutableArray array]; 39 | 40 | if (!self.startEndSegmentButton) { 41 | self.startEndSegmentButton = [UIButton buttonWithType:UIButtonTypeCustom]; 42 | self.startEndSegmentButton.backgroundColor = UIColor.systemBlueColor; 43 | [self.startEndSegmentButton addTarget:self action:@selector(startEndSegmentButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; 44 | 45 | if (self.playerViewController.userSkipSegments.lastObject.endTime != -1) [self.startEndSegmentButton setTitle:LOC(@"SegmentStartsNow") forState:UIControlStateNormal]; 46 | else [self.startEndSegmentButton setTitle:LOC(@"SegmentEndsNow") forState:UIControlStateNormal]; 47 | self.startEndSegmentButton.titleLabel.adjustsFontSizeToFitWidth = YES; 48 | 49 | [self.playerViewController.view addSubview:self.startEndSegmentButton]; 50 | 51 | self.startEndSegmentButton.layer.cornerRadius = 12; 52 | self.startEndSegmentButton.frame = CGRectMake(0,0,512,50); 53 | self.startEndSegmentButton.translatesAutoresizingMaskIntoConstraints = NO; 54 | 55 | [self.startEndSegmentButton.topAnchor constraintEqualToAnchor:self.playerViewController.view.bottomAnchor constant:10].active = YES; 56 | [self.startEndSegmentButton.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor].active = YES; 57 | [self.startEndSegmentButton.widthAnchor constraintEqualToConstant:self.view.frame.size.width/2].active = YES; 58 | [self.startEndSegmentButton.heightAnchor constraintEqualToConstant:50].active = YES; 59 | self.startEndSegmentButton.clipsToBounds = YES; 60 | } 61 | 62 | self.whitelistChannelLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 63 | self.whitelistChannelLabel.text = LOC(@"WhitelistChannel"); 64 | [self.playerViewController.view addSubview:self.whitelistChannelLabel]; 65 | self.whitelistChannelLabel.translatesAutoresizingMaskIntoConstraints = NO; 66 | [self.whitelistChannelLabel.topAnchor constraintEqualToAnchor:self.startEndSegmentButton.bottomAnchor constant:10].active = YES; 67 | [self.whitelistChannelLabel.centerXAnchor constraintEqualToAnchor:self.startEndSegmentButton.centerXAnchor].active = YES; 68 | [self.whitelistChannelLabel.widthAnchor constraintEqualToConstant:185].active = YES; 69 | [self.whitelistChannelLabel.heightAnchor constraintEqualToConstant:31].active = YES; 70 | self.whitelistChannelLabel.userInteractionEnabled = YES; 71 | 72 | UISwitch *whitelistSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0,0,51,31)]; 73 | [whitelistSwitch addTarget:self action:@selector(whitelistSwitchToggled:) forControlEvents:UIControlEventValueChanged]; 74 | [self.whitelistChannelLabel addSubview:whitelistSwitch]; 75 | whitelistSwitch.translatesAutoresizingMaskIntoConstraints = NO; 76 | [whitelistSwitch.leadingAnchor constraintEqualToAnchor:self.whitelistChannelLabel.trailingAnchor constant:-51].active = YES; 77 | [whitelistSwitch.centerYAnchor constraintEqualToAnchor:self.whitelistChannelLabel.centerYAnchor].active = YES; 78 | 79 | if ([kWhitelistedChannels containsObject:self.playerViewController.channelID]) { 80 | [whitelistSwitch setOn:YES animated:NO]; 81 | } 82 | else { 83 | [whitelistSwitch setOn:NO animated:NO]; 84 | } 85 | 86 | YTPlayerView *playerView = (YTPlayerView *)self.playerViewController.view; 87 | NSArray *skipSegments = [self skipSegments]; 88 | if (skipSegments.count > 0) { 89 | self.segmentsInDatabaseLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 90 | self.segmentsInDatabaseLabel.userInteractionEnabled = YES; 91 | 92 | self.segmentsInDatabaseLabel.text = LOC(@"SegmentsInDatabase"); 93 | self.segmentsInDatabaseLabel.numberOfLines = 1; 94 | self.segmentsInDatabaseLabel.adjustsFontSizeToFitWidth = YES; 95 | self.segmentsInDatabaseLabel.textAlignment = NSTextAlignmentCenter; 96 | 97 | [playerView addSubview:self.segmentsInDatabaseLabel]; 98 | self.segmentsInDatabaseLabel.translatesAutoresizingMaskIntoConstraints = NO; 99 | 100 | [self.segmentsInDatabaseLabel.topAnchor constraintEqualToAnchor:self.whitelistChannelLabel.bottomAnchor constant:-15].active = YES; 101 | [self.segmentsInDatabaseLabel.centerXAnchor constraintEqualToAnchor:playerView.centerXAnchor].active = YES; 102 | [self.segmentsInDatabaseLabel.widthAnchor constraintEqualToAnchor:playerView.widthAnchor].active = YES; 103 | [self.segmentsInDatabaseLabel.heightAnchor constraintEqualToConstant:75.0f].active = YES; 104 | 105 | self.sponsorSegmentViews = [self segmentViewsForSegments:skipSegments editable:NO]; 106 | 107 | for (int i = 0; i < self.sponsorSegmentViews.count; i++) { 108 | [self.segmentsInDatabaseLabel addSubview:self.sponsorSegmentViews[i]]; 109 | [self.sponsorSegmentViews[i] addInteraction:[[UIContextMenuInteraction alloc] initWithDelegate:self]]; 110 | 111 | self.sponsorSegmentViews[i].translatesAutoresizingMaskIntoConstraints = NO; 112 | [self.sponsorSegmentViews[i].widthAnchor constraintEqualToConstant:playerView.frame.size.width/self.sponsorSegmentViews.count-10].active = YES; 113 | [self.sponsorSegmentViews[i].heightAnchor constraintEqualToConstant:30].active = YES; 114 | [self.sponsorSegmentViews[i].topAnchor constraintEqualToAnchor:self.segmentsInDatabaseLabel.bottomAnchor constant:-25].active = YES; 115 | 116 | if (self.sponsorSegmentViews.count == 1) { 117 | [self.sponsorSegmentViews[i].centerXAnchor constraintEqualToAnchor:self.segmentsInDatabaseLabel.centerXAnchor].active = YES; 118 | break; 119 | } 120 | 121 | if (i > 0) { 122 | [self.sponsorSegmentViews[i].leftAnchor constraintEqualToAnchor:self.sponsorSegmentViews[i-1].rightAnchor constant:5].active = YES; 123 | } 124 | else { 125 | [self.sponsorSegmentViews[i].leftAnchor constraintEqualToAnchor:self.segmentsInDatabaseLabel.leftAnchor constant:5*(self.sponsorSegmentViews.count / 2)].active = YES; 126 | } 127 | } 128 | 129 | } 130 | 131 | if (self.playerViewController.userSkipSegments.count > 0) { 132 | self.userSegmentsLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 133 | self.userSegmentsLabel.userInteractionEnabled = YES; 134 | 135 | self.userSegmentsLabel.text = LOC(@"YourSegments"); 136 | 137 | self.userSponsorSegmentViews = [self segmentViewsForSegments:self.playerViewController.userSkipSegments editable:YES]; 138 | for (int i = 0; i < self.userSponsorSegmentViews.count; i++) { 139 | [self.userSegmentsLabel addSubview:self.userSponsorSegmentViews[i]]; 140 | [self.userSponsorSegmentViews[i] addInteraction:[[UIContextMenuInteraction alloc] initWithDelegate:self]]; 141 | 142 | self.userSponsorSegmentViews[i].translatesAutoresizingMaskIntoConstraints = NO; 143 | [self.userSponsorSegmentViews[i].widthAnchor constraintEqualToConstant:playerView.frame.size.width/self.userSponsorSegmentViews.count-10].active = YES; 144 | [self.userSponsorSegmentViews[i].heightAnchor constraintEqualToConstant:30].active = YES; 145 | [self.userSponsorSegmentViews[i].topAnchor constraintEqualToAnchor:self.userSegmentsLabel.bottomAnchor constant:-25].active = YES; 146 | 147 | if (self.userSponsorSegmentViews.count == 1) { 148 | [self.userSponsorSegmentViews[i].centerXAnchor constraintEqualToAnchor:self.userSegmentsLabel.centerXAnchor].active = YES; 149 | break; 150 | } 151 | 152 | if (i > 0) { 153 | [self.userSponsorSegmentViews[i].leftAnchor constraintEqualToAnchor:self.userSponsorSegmentViews[i-1].rightAnchor constant:5].active = YES; 154 | } 155 | else { 156 | [self.userSponsorSegmentViews[i].leftAnchor constraintEqualToAnchor:self.userSegmentsLabel.leftAnchor constant:5*(self.userSponsorSegmentViews.count / 2)].active = YES; 157 | } 158 | } 159 | self.userSegmentsLabel.numberOfLines = 2; 160 | self.userSegmentsLabel.adjustsFontSizeToFitWidth = YES; 161 | self.userSegmentsLabel.textAlignment = NSTextAlignmentCenter; 162 | 163 | [playerView addSubview:self.userSegmentsLabel]; 164 | self.userSegmentsLabel.translatesAutoresizingMaskIntoConstraints = NO; 165 | 166 | if (skipSegments.count > 0) [self.userSegmentsLabel.topAnchor constraintEqualToAnchor:self.segmentsInDatabaseLabel.bottomAnchor constant:-10].active = YES; 167 | else [self.userSegmentsLabel.topAnchor constraintEqualToAnchor:self.whitelistChannelLabel.bottomAnchor constant:-10].active = YES; 168 | 169 | [self.userSegmentsLabel.centerXAnchor constraintEqualToAnchor:playerView.centerXAnchor].active = YES; 170 | [self.userSegmentsLabel.widthAnchor constraintEqualToAnchor:playerView.widthAnchor].active = YES; 171 | [self.userSegmentsLabel.heightAnchor constraintEqualToConstant:75.0f].active = YES; 172 | 173 | self.submitSegmentsButton = [UIButton buttonWithType:UIButtonTypeCustom]; 174 | self.submitSegmentsButton.backgroundColor = UIColor.systemBlueColor; 175 | 176 | [self.submitSegmentsButton addTarget:self action:@selector(submitSegmentsButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; 177 | [self.submitSegmentsButton setTitle:LOC(@"SubmitSegments") forState:UIControlStateNormal]; 178 | 179 | [playerView addSubview:self.submitSegmentsButton]; 180 | self.submitSegmentsButton.layer.cornerRadius = 12; 181 | self.submitSegmentsButton.frame = CGRectMake(0,0,512,50); 182 | 183 | self.submitSegmentsButton.translatesAutoresizingMaskIntoConstraints = NO; 184 | [self.submitSegmentsButton.topAnchor constraintEqualToAnchor:self.userSegmentsLabel.bottomAnchor constant:15].active = YES; 185 | [self.submitSegmentsButton.centerXAnchor constraintEqualToAnchor:playerView.centerXAnchor].active = YES; 186 | [self.submitSegmentsButton.widthAnchor constraintEqualToConstant:self.view.frame.size.width/2].active = YES; 187 | [self.submitSegmentsButton.heightAnchor constraintEqualToConstant:50].active = YES; 188 | self.submitSegmentsButton.clipsToBounds = YES; 189 | } 190 | } 191 | 192 | - (void)whitelistSwitchToggled:(UISwitch *)sender { 193 | if (sender.isOn) { 194 | [kWhitelistedChannels addObject:self.playerViewController.channelID]; 195 | } 196 | else { 197 | [kWhitelistedChannels removeObject:self.playerViewController.channelID]; 198 | } 199 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 200 | NSString *documentsDirectory = [paths objectAtIndex:0]; 201 | NSString *settingsPath = [documentsDirectory stringByAppendingPathComponent:@"iSponsorBlock.plist"]; 202 | NSMutableDictionary *settings = [NSMutableDictionary dictionary]; 203 | [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:settingsPath]]; 204 | 205 | [settings setValue:kWhitelistedChannels forKey:@"whitelistedChannels"]; 206 | [settings writeToURL:[NSURL fileURLWithPath:settingsPath isDirectory:NO] error:nil]; 207 | CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.galacticdev.isponsorblockprefs.changed"), NULL, NULL, YES); 208 | } 209 | 210 | - (void)viewDidDisappear:(BOOL)animated { 211 | [super viewDidDisappear:animated]; 212 | [self.startEndSegmentButton removeFromSuperview]; 213 | [self.segmentsInDatabaseLabel removeFromSuperview]; 214 | [self.userSegmentsLabel removeFromSuperview]; 215 | [self.submitSegmentsButton removeFromSuperview]; 216 | [self.whitelistChannelLabel removeFromSuperview]; 217 | 218 | [self.previousParentViewController addChildViewController:self.playerViewController]; 219 | [self.previousParentViewController.view addSubview:self.playerViewController.view]; 220 | 221 | self.overlayView.isDisplayingSponsorBlockViewController = NO; 222 | self.overlayView.sponsorBlockButton.hidden = NO; 223 | self.overlayView.sponsorStartedEndedButton.hidden = NO; 224 | [self.overlayView setOverlayVisible:YES]; 225 | } 226 | 227 | - (void)startEndSegmentButtonPressed:(UIButton *)sender { 228 | NSString *segmentStartsNowTitle = LOC(@"SegmentStartsNow"); 229 | NSString *segmentEndsNowTitle = LOC(@"SegmentEndsNow"); 230 | NSString *errorTitle = LOC(@"Error"); 231 | NSString *okTitle = LOC(@"OK"); 232 | NSInteger minutes = lroundf(self.playerViewController.userSkipSegments.lastObject.startTime)/60; 233 | NSInteger seconds = lroundf(self.playerViewController.userSkipSegments.lastObject.startTime)%60; 234 | NSString *errorMessage = [NSString stringWithFormat:@"%@ %ld:%02ld", LOC(@"EndTimeLessThanStartTime"), minutes, seconds]; 235 | 236 | if ([sender.titleLabel.text isEqualToString:segmentStartsNowTitle]) { 237 | [self.playerViewController.userSkipSegments addObject:[[SponsorSegment alloc] initWithStartTime:self.playerViewController.currentVideoMediaTime endTime:-1 category:nil UUID:nil]]; 238 | [sender setTitle:segmentEndsNowTitle forState:UIControlStateNormal]; 239 | } else { 240 | self.playerViewController.userSkipSegments.lastObject.endTime = self.playerViewController.currentVideoMediaTime; 241 | if (self.playerViewController.userSkipSegments.lastObject.endTime != self.playerViewController.currentVideoMediaTime) { 242 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:errorTitle message:errorMessage preferredStyle:UIAlertControllerStyleAlert]; 243 | UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:okTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {}]; 244 | [alert addAction:defaultAction]; 245 | [self presentViewController:alert animated:YES completion:nil]; 246 | return; 247 | } 248 | [sender setTitle:segmentStartsNowTitle forState:UIControlStateNormal]; 249 | } 250 | [self setupViews]; 251 | } 252 | 253 | - (void)submitSegmentsButtonPressed:(UIButton *)sender { 254 | for (SponsorSegment *segment in self.playerViewController.userSkipSegments) { 255 | if (segment.endTime == -1 || !segment.category) { 256 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOC(@"Error") message:LOC(@"UnfinishedSegments") preferredStyle:UIAlertControllerStyleAlert]; 257 | UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:LOC(@"OK") style:UIAlertActionStyleDefault 258 | handler:^(UIAlertAction * action) {}]; 259 | [alert addAction:defaultAction]; 260 | [self presentViewController:alert animated:YES completion:nil]; 261 | return; 262 | } 263 | } 264 | 265 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 266 | NSString *documentsDirectory = [paths objectAtIndex:0]; 267 | NSString *settingsPath = [documentsDirectory stringByAppendingPathComponent:@"iSponsorBlock.plist"]; 268 | NSMutableDictionary *settings = [NSMutableDictionary dictionary]; 269 | [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:settingsPath]]; 270 | 271 | [SponsorBlockRequest postSponsorTimes:self.playerViewController.currentVideoID sponsorSegments:self.playerViewController.userSkipSegments userID:kUserID withViewController:self.previousParentViewController]; 272 | [self.previousParentViewController dismissViewControllerAnimated:YES completion:nil]; 273 | } 274 | 275 | - (NSMutableArray *)segmentViewsForSegments:(NSArray *)segments editable:(BOOL)editable { 276 | for (SponsorSegment *segment in segments) { 277 | if (!editable) { 278 | [self.sponsorSegmentViews addObject:[[SponsorSegmentView alloc] initWithFrame:CGRectMake(0,0,50,30) sponsorSegment:segment editable:editable]]; 279 | } 280 | else { 281 | [self.userSponsorSegmentViews addObject:[[SponsorSegmentView alloc] initWithFrame:CGRectMake(0,0,50,30) sponsorSegment:segment editable:editable]]; 282 | } 283 | } 284 | if (!editable) return self.sponsorSegmentViews; 285 | return self.userSponsorSegmentViews; 286 | } 287 | 288 | 289 | - (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction 290 | configurationForMenuAtLocation:(CGPoint)location { 291 | SponsorSegmentView *sponsorSegmentView = interaction.view; 292 | 293 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 294 | NSString *documentsDirectory = [paths objectAtIndex:0]; 295 | NSString *path = [documentsDirectory stringByAppendingPathComponent:@"iSponsorBlock.plist"]; 296 | NSMutableDictionary *settings = [NSMutableDictionary dictionary]; 297 | [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]]; 298 | 299 | UIContextMenuConfiguration *config = [UIContextMenuConfiguration configurationWithIdentifier:nil 300 | previewProvider:nil 301 | actionProvider:^UIMenu* _Nullable(NSArray* _Nonnull suggestedActions) { 302 | NSMutableArray *categoryActions = [NSMutableArray array]; 303 | [categoryActions addObject:[UIAction actionWithTitle:LOC(@"Sponsor") image:nil identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 304 | if (sponsorSegmentView.editable) { 305 | sponsorSegmentView.sponsorSegment.category = @"sponsor"; 306 | [self setupViews]; 307 | return; 308 | } 309 | [SponsorBlockRequest categoryVoteForSegment:sponsorSegmentView.sponsorSegment userID:[settings objectForKey:@"userID"] category:@"sponsor" withViewController:self]; 310 | }]]; 311 | 312 | [categoryActions addObject:[UIAction actionWithTitle:LOC(@"Intermission/IntroAnimation") image:nil identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 313 | if (sponsorSegmentView.editable) { 314 | sponsorSegmentView.sponsorSegment.category = @"intro"; 315 | [self setupViews]; 316 | return; 317 | } 318 | [SponsorBlockRequest categoryVoteForSegment:sponsorSegmentView.sponsorSegment userID:[settings objectForKey:@"userID"] category:@"intro" withViewController:self]; 319 | }]]; 320 | 321 | [categoryActions addObject:[UIAction actionWithTitle:LOC(@"Outro") image:nil identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 322 | if (sponsorSegmentView.editable) { 323 | sponsorSegmentView.sponsorSegment.category = @"outro"; 324 | [self setupViews]; 325 | return; 326 | } 327 | [SponsorBlockRequest categoryVoteForSegment:sponsorSegmentView.sponsorSegment userID:[settings objectForKey:@"userID"] category:@"outro" withViewController:self]; 328 | }]]; 329 | 330 | [categoryActions addObject:[UIAction actionWithTitle:LOC(@"InteractionReminder_Subcribe/Like") image:nil identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 331 | if (sponsorSegmentView.editable) { 332 | sponsorSegmentView.sponsorSegment.category = @"interaction"; 333 | [self setupViews]; 334 | return; 335 | } 336 | [SponsorBlockRequest categoryVoteForSegment:sponsorSegmentView.sponsorSegment userID:[settings objectForKey:@"userID"] category:@"interaction" withViewController:self]; 337 | }]]; 338 | 339 | [categoryActions addObject:[UIAction actionWithTitle:LOC(@"Unpaid/SelfPromotion") image:nil identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 340 | if (sponsorSegmentView.editable) { 341 | sponsorSegmentView.sponsorSegment.category = @"selfpromo"; 342 | [self setupViews]; 343 | return; 344 | } 345 | [SponsorBlockRequest categoryVoteForSegment:sponsorSegmentView.sponsorSegment userID:[settings objectForKey:@"userID"] category:@"selfpromo" withViewController:self]; 346 | }]]; 347 | 348 | [categoryActions addObject:[UIAction actionWithTitle:LOC(@"Non-MusicSection") image:nil identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 349 | if (sponsorSegmentView.editable) { 350 | sponsorSegmentView.sponsorSegment.category = @"music_offtopic"; 351 | [self setupViews]; 352 | return; 353 | } 354 | [SponsorBlockRequest categoryVoteForSegment:sponsorSegmentView.sponsorSegment userID:[settings objectForKey:@"userID"] category:@"music_offtopic" withViewController:self]; 355 | }]]; 356 | 357 | [categoryActions addObject:[UIAction actionWithTitle:LOC(@"Preview") image:nil identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 358 | if (sponsorSegmentView.editable) { 359 | sponsorSegmentView.sponsorSegment.category = @"preview"; 360 | [self setupViews]; 361 | return; 362 | } 363 | [SponsorBlockRequest categoryVoteForSegment:sponsorSegmentView.sponsorSegment userID:[settings objectForKey:@"userID"] category:@"preview" withViewController:self]; 364 | }]]; 365 | 366 | NSMutableArray* actions = [NSMutableArray array]; 367 | if (sponsorSegmentView.editable) { 368 | [actions addObject:[UIAction actionWithTitle:LOC(@"EditStartTime") image:[UIImage systemImageNamed:@"arrow.left.to.line"] identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 369 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOC(@"Edit") message:LOC(@"EditStartTime_Desc") preferredStyle:UIAlertControllerStyleAlert]; 370 | UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:LOC(@"OK") style:UIAlertActionStyleDefault 371 | handler:^(UIAlertAction * action) { 372 | NSNumberFormatter *f = [[NSNumberFormatter alloc] init]; 373 | f.numberStyle = NSNumberFormatterDecimalStyle; 374 | 375 | NSArray *strings = [alert.textFields[0].text componentsSeparatedByString:@":"]; 376 | if (strings.count != 2) return; 377 | NSString *minutesString = strings[0]; 378 | NSString *secondsString = strings[1]; 379 | 380 | CGFloat minutes = [[f numberFromString:minutesString] floatValue]; 381 | CGFloat seconds = [[f numberFromString:secondsString] floatValue]; 382 | sponsorSegmentView.sponsorSegment.startTime = (minutes*60)+seconds; 383 | [self setupViews]; 384 | }]; 385 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:LOC(@"Cancel") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 386 | 387 | }]; 388 | [alert addAction:defaultAction]; 389 | [alert addAction:cancelAction]; 390 | [alert addTextFieldWithConfigurationHandler:nil]; 391 | [self presentViewController:alert animated:YES completion:nil]; 392 | }]]; 393 | 394 | [actions addObject:[UIAction actionWithTitle:LOC(@"EditEndTime") image:[UIImage systemImageNamed:@"arrow.right.to.line"] identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 395 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOC(@"Edit") message:LOC(@"EditEndTime_Desc") preferredStyle:UIAlertControllerStyleAlert]; 396 | UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:LOC(@"OK") style:UIAlertActionStyleDefault 397 | handler:^(UIAlertAction * action) { 398 | NSNumberFormatter *f = [[NSNumberFormatter alloc] init]; 399 | f.numberStyle = NSNumberFormatterDecimalStyle; 400 | 401 | NSArray *strings = [alert.textFields[0].text componentsSeparatedByString:@":"]; 402 | if (strings.count != 2) return; 403 | NSString *minutesString = strings[0]; 404 | NSString *secondsString = strings[1]; 405 | 406 | CGFloat minutes = [[f numberFromString:minutesString] floatValue]; 407 | CGFloat seconds = [[f numberFromString:secondsString] floatValue]; 408 | sponsorSegmentView.sponsorSegment.endTime = (minutes*60)+seconds; 409 | [self setupViews]; 410 | }]; 411 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:LOC(@"Cancel") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 412 | 413 | }]; 414 | [alert addAction:defaultAction]; 415 | [alert addAction:cancelAction]; 416 | [alert addTextFieldWithConfigurationHandler:nil]; 417 | [self presentViewController:alert animated:YES completion:nil]; 418 | }]]; 419 | 420 | UIMenu *categoriesMenu = [UIMenu menuWithTitle:LOC(@"EditCategory") image:[UIImage systemImageNamed:@"square.grid.2x2"] identifier:nil options:0 children:categoryActions]; 421 | [actions addObject:categoriesMenu]; 422 | [actions addObject:[UIAction actionWithTitle:LOC(@"Delete") image:[UIImage systemImageNamed:@"trash"] identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 423 | [self.playerViewController.userSkipSegments removeObject:sponsorSegmentView.sponsorSegment]; 424 | [self setupViews]; 425 | }]]; 426 | 427 | UIMenu* menu = [UIMenu menuWithTitle:LOC(@"EditSegment") children:actions]; 428 | return menu; 429 | } 430 | else { 431 | [actions addObject:[UIAction actionWithTitle:LOC(@"Upvote") image:[UIImage systemImageNamed:@"hand.thumbsup.fill"] identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 432 | [SponsorBlockRequest normalVoteForSegment:sponsorSegmentView.sponsorSegment userID:[settings objectForKey:@"userID"] type:YES withViewController:self]; 433 | }]]; 434 | 435 | [actions addObject:[UIAction actionWithTitle:LOC(@"Downvote") image:[UIImage systemImageNamed:@"hand.thumbsdown.fill"] identifier:nil handler:^(__kindof UIAction* _Nonnull action) { 436 | [SponsorBlockRequest normalVoteForSegment:sponsorSegmentView.sponsorSegment userID:[settings objectForKey:@"userID"] type:NO withViewController:self]; 437 | }]]; 438 | 439 | UIMenu *categoriesMenu = [UIMenu menuWithTitle:LOC(@"VoteToChangeCategory") image:[UIImage systemImageNamed:@"square.grid.2x2"] identifier:nil options:0 children:categoryActions]; 440 | UIMenu* menu = [UIMenu menuWithTitle:LOC(@"VoteOnSegment") children:[actions arrayByAddingObject:categoriesMenu]]; 441 | return menu; 442 | } 443 | }]; 444 | return config; 445 | } 446 | @end 447 | -------------------------------------------------------------------------------- /SponsorSegment.m: -------------------------------------------------------------------------------- 1 | #import "Headers/SponsorSegment.h" 2 | 3 | @implementation SponsorSegment 4 | - (instancetype)initWithStartTime:(CGFloat)startTime endTime:(CGFloat)endTime category:(NSString *)category UUID:(NSString *)UUID { 5 | self = [super init]; 6 | if (self) { 7 | self.startTime = startTime; 8 | self.endTime = endTime; 9 | self.category = category; 10 | self.UUID = UUID; 11 | } 12 | return self; 13 | } 14 | - (void)setEndTime:(CGFloat)endTime { 15 | if (endTime < self.startTime) { 16 | _endTime = -1; 17 | return; 18 | } 19 | _endTime = endTime; 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /SponsorSegmentView.m: -------------------------------------------------------------------------------- 1 | #import "Headers/SponsorSegmentView.h" 2 | #import "Headers/Localization.h" 3 | 4 | @implementation SponsorSegmentView 5 | - (instancetype)initWithFrame:(CGRect)frame sponsorSegment:(SponsorSegment *)segment editable:(BOOL)editable { 6 | self = [super initWithFrame:frame]; 7 | if (self) { 8 | self.sponsorSegment = segment; 9 | self.editable = editable; 10 | 11 | NSString *category; 12 | if ([segment.category isEqualToString:@"sponsor"]) { 13 | category = LOC(@"Sponsor"); 14 | } 15 | else if ([segment.category isEqualToString:@"intro"]) { 16 | category = LOC(@"Intermission"); 17 | } 18 | else if ([segment.category isEqualToString:@"outro"]) { 19 | category = LOC(@"Outro"); 20 | } 21 | else if ([segment.category isEqualToString:@"interaction"]) { 22 | category = LOC(@"Interaction"); 23 | } 24 | else if ([segment.category isEqualToString:@"selfpromo"]) { 25 | category = LOC(@"SelfPromo"); 26 | } 27 | else if ([segment.category isEqualToString:@"music_offtopic"]) { 28 | category = LOC(@"Non-Music"); 29 | } 30 | else if ([segment.category isEqualToString:@"preview"]) { 31 | category = LOC(@"Preview"); 32 | } 33 | self.categoryLabel = [[UILabel alloc] initWithFrame:self.frame]; 34 | self.segmentLabel = [[UILabel alloc] initWithFrame:self.frame]; 35 | self.categoryLabel.text = category; 36 | 37 | NSInteger startSeconds = lroundf(segment.startTime); 38 | NSInteger startHours = startSeconds / 3600; 39 | NSInteger startMinutes = (startSeconds - (startHours * 3600)) / 60; 40 | startSeconds = startSeconds %60; 41 | NSString *startTime; 42 | if (startHours >= 1) { 43 | startTime = [NSString stringWithFormat:@"%ld:%02ld:%02ld", startHours, startMinutes, startSeconds]; 44 | } 45 | else { 46 | startTime = [NSString stringWithFormat:@"%ld:%02ld", startMinutes, startSeconds]; 47 | } 48 | 49 | NSInteger endSeconds = lroundf(segment.endTime); 50 | NSInteger endHours = endSeconds / 3600; 51 | NSInteger endMinutes = (endSeconds - (endHours * 3600)) / 60; 52 | endSeconds = endSeconds %60; 53 | NSString *endTime; 54 | if (endHours >= 1) { 55 | endTime = [NSString stringWithFormat:@"%ld:%02ld:%02ld", endHours, endMinutes, endSeconds]; 56 | } 57 | else { 58 | endTime = [NSString stringWithFormat:@"%ld:%02ld", endMinutes, endSeconds]; 59 | } 60 | 61 | self.segmentLabel.text = [NSString stringWithFormat:@"%@ %@ %@ %@", LOC(@"From"), startTime, LOC(@"to"), endTime]; 62 | 63 | [self addSubview:self.categoryLabel]; 64 | self.categoryLabel.adjustsFontSizeToFitWidth = YES; 65 | self.categoryLabel.font = [UIFont systemFontOfSize:12]; 66 | self.categoryLabel.textAlignment = NSTextAlignmentCenter; 67 | self.categoryLabel.translatesAutoresizingMaskIntoConstraints = NO; 68 | 69 | [self addSubview:self.segmentLabel]; 70 | self.segmentLabel.adjustsFontSizeToFitWidth = YES; 71 | self.segmentLabel.font = [UIFont systemFontOfSize:12]; 72 | self.segmentLabel.textAlignment = NSTextAlignmentCenter; 73 | self.segmentLabel.translatesAutoresizingMaskIntoConstraints = NO; 74 | 75 | [self.segmentLabel.widthAnchor constraintEqualToAnchor:self.widthAnchor].active = YES; 76 | [self.segmentLabel.heightAnchor constraintEqualToConstant:self.frame.size.height/2].active = YES; 77 | 78 | [self.categoryLabel.widthAnchor constraintEqualToAnchor:self.widthAnchor].active = YES; 79 | [self.categoryLabel.heightAnchor constraintEqualToConstant:self.frame.size.height/2].active = YES; 80 | [self.categoryLabel.topAnchor constraintEqualToAnchor:self.segmentLabel.bottomAnchor].active = YES; 81 | 82 | self.backgroundColor = UIColor.systemGray4Color; 83 | self.layer.cornerRadius = 10; 84 | self.segmentLabel.layer.cornerRadius = 10; 85 | self.categoryLabel.layer.cornerRadius = 10; 86 | } 87 | return self; 88 | } 89 | @end 90 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.galacticdev.isponsorblock 2 | Name: iSponsorBlock 3 | Version: 1.2.12 4 | Architecture: iphoneos-arm 5 | Description: SponsorBlock port for iOS 6 | Maintainer: Galactic Dev 7 | Author: Galactic Dev 8 | Section: Tweaks 9 | Depends: mobilesubstrate (>= 0.9.5000), ws.hbang.alderis (>= 1.1), firmware (>= 13.0) 10 | Icon: https://raw.githubusercontent.com/ajayyy/SponsorBlock/master/public/icons/LogoSponsorBlocker64px.png 11 | Depiction: https://galacticdev.me/iSponsorBlock 12 | -------------------------------------------------------------------------------- /iSponsorBlock.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.google.ios.youtube" ); }; } 2 | -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Galactic-Dev/iSponsorBlock/3e4157c2a84576d175fc73ae422927e3d2531055/layout/Library/Application Support/iSponsorBlock.bundle/Info.plist -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/LogoSponsorBlocker128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Galactic-Dev/iSponsorBlock/3e4157c2a84576d175fc73ae422927e3d2531055/layout/Library/Application Support/iSponsorBlock.bundle/LogoSponsorBlocker128px.png -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/PlayerInfoIconSponsorBlocker256px-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Galactic-Dev/iSponsorBlock/3e4157c2a84576d175fc73ae422927e3d2531055/layout/Library/Application Support/iSponsorBlock.bundle/PlayerInfoIconSponsorBlocker256px-20@2x.png -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/SponsorAudio.m4a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Galactic-Dev/iSponsorBlock/3e4157c2a84576d175fc73ae422927e3d2531055/layout/Library/Application Support/iSponsorBlock.bundle/SponsorAudio.m4a -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/de.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* iSponsorBlock Settings */ 2 | "Enabled" = "iSponsorBlock An-/Ausschalten"; 3 | "RestartFooter" = "Bitte starten Sie die YouTube App neu, damit die Änderungen wirksam werden."; 4 | 5 | "Sponsor" = "Sponsor-Segmente"; 6 | "Intermission/IntroAnimation" = "Unterbrechung/Intro"; 7 | "Intermission" = "Unterbrechung"; 8 | "Endcards/Credits" = "Endkarte/Credits"; 9 | "Outro" = "Outro"; 10 | "InteractionReminder" = "Interaktionserinnerung (Abonnieren/Liken)"; 11 | "InteractionReminder_Subcribe/Like" = "Interaktionserinnerung (Abonnieren/Liken)"; 12 | "Interaction" = "Interaktion"; 13 | "Unpaid/SelfPromotion" = "Unbezahlt/Eigenwerbung"; 14 | "SelfPromo" = "Eigenwerbung"; 15 | "Non-MusicSection" = "Musik: Segmente ohne Musik"; 16 | "Non-Music" = "Keine Musik"; 17 | "Preview" = "Preview"; 18 | "SponsorBlockUserID" = "SponsorBlock Benutzer-ID"; 19 | "SponsorBlockAPIInstance" = "SponsorBlock API-Instanz"; 20 | 21 | "Disable" = "Aus"; 22 | "AutoSkip" = "Automatisch"; 23 | "ShowInSeekBar" = "Nur Einfärben"; 24 | "ManualSkip" = "Manuell"; 25 | "SetColorToShowInSeekBar" = "Farbe des Segments in der Zeitleiste"; 26 | "UserID" = "Benutzer-ID:"; 27 | "UserIDFooter" = "Wenn Sie eine benutzerdefinierte Benutzer-ID für iSponsorBlock verwenden möchten, können Sie diese hier einfügen. Falls Sie nicht wissen, was das sein soll, verändern Sie diesen Wert bitte nicht."; 28 | "API_URL" = "API-URL:"; 29 | "APIFooter" = "Wenn Sie eine benutzerdefinierte API-Instanz für iSponsorBlock verwenden möchten, können Sie diese hier einfügen. Falls Sie nicht wissen, was das sein soll, verändern Sie diesen Wert bitte nicht. \nBeispiel: https://sponsor.ajay.app/api"; 30 | "MinimumSegmentDuration" = "Minimale Segmentdauer festlegen:"; 31 | "HowLongNoticeWillAppear" = "Anzeigedauer des Skip-Hinweises:"; 32 | "ShowSkipNotice" = "Skip-Hinweis einblenden"; 33 | "ShowButtonsInPlayer" = "Tasten im Video-Overlay anzeigen"; 34 | "HideStartEndButtonInPlayer" = "Start- & Endtaste ausblenden"; 35 | "ShowModifiedTime" = "Angepasste Videolänge anzeigen"; 36 | "AudioNotificationOnSkip" = "Hinweiston beim Überspringen"; 37 | "AudioFooter" = "Im Stummmodus nicht verfügbar!"; 38 | "EnableSkipCountTracking" = "Tracking der Skip-Anzahl"; 39 | "DonateOnVenmo" = "Unterstütze uns über Venmo!"; 40 | "DonateOnPayPal" = "Unterstütze uns über PayPal!"; 41 | 42 | /* Segments stuff */ 43 | "SegmentStartsNow" = "Segment beginnt jetzt"; 44 | "SegmentEndsNow" = "Segment endet jetzt"; 45 | "WhitelistChannel" = "Kanal whitelisten"; 46 | "SegmentsInDatabase" = "Es gibt bereits Segmente in der Datenbank:"; 47 | "YourSegments" = "Deine Segmente:"; 48 | "SubmitSegments" = "Segmente übermitteln"; 49 | "SuccessfullySubmittedSegments" = "Segmente erfolgreich übermittelt"; 50 | "EndTimeLessThanStartTime" = "Die von Ihnen eingereichte Endzeit liegt vor der Startzeit, bitte wählen Sie eine Zeit danach"; //Beispiel: ..., Bitte wählen Sie einen Zeitpunkt nach 10:15 51 | "UnfinishedSegments" = "Sie haben nicht veröffentlichte Segmente\n Bitte spezifizieren Sie die Kategorie und/oder fügen Sie eine Endzeit zu Ihren Segmenten hinzu"; 52 | "EditStartTime" = "Startzeit bearbeiten"; 53 | "EditStartTime_Desc" = "Startzeit bearbeiten: (z.B. 1:15)"; 54 | "EditEndTime" = "Endzeit bearbeiten"; 55 | "EditEndTime_Desc" = "Endzeit bearbeiten: (z.B. 1:15)"; 56 | "From" = "Von"; // Zeit. Beispiel: Von 1:15 bis 3:00. Falls Sie dies nicht benötigen, lassen Sie es einfach leer 57 | "to" = "bis"; // Zeit. Beispiel: Von 1:15 bis 3:00 58 | "EditCategory" = "Kategorie bearbeiten"; 59 | "EditSegment" = "Segment bearbeiten"; 60 | "Edit" = "Bearbeiten"; 61 | "Error" = "Fehler"; 62 | "ErrorCode" = "Fehlercode"; 63 | "Success" = "Erfolgreich"; 64 | "OK" = "OK"; 65 | "Cancel" = "Abbrechen"; 66 | "Delete" = "Löschen"; 67 | "Upvote" = "Upvoten"; 68 | "Downvote" = "Downvoten"; 69 | "VoteToChangeCategory" = "Abstimmen zum Ändern der Kategorie"; 70 | "VoteOnSegment" = "Abstimmung über das Segment"; 71 | "SuccessfullyVoted" = "Erfolgreich abgestimmt"; 72 | "ErrorVoting" = "Fehler beim Abstimmen"; 73 | 74 | /* Pop-ups*/ 75 | "ManuallySkipReminder" = "Manuelles Überspringen des %@ Segments\nvon %ld:%02ld zu %ld:%02ld?"; 76 | "Skip" = "Überspringen"; 77 | "SkippedSegment" = "%@ Segment übersprungen"; 78 | "Unskip" = "Zurückspringen"; 79 | 80 | /* Segments in pop-ups*/ 81 | "sponsor" = "Sponsor"; 82 | "intro" = "Intro"; 83 | "outro" = "Outro"; 84 | "interaction" = "Interaktion"; 85 | "selfpromo" = "Eigenwerbung"; 86 | "music_offtopic" = "Keine Musik"; 87 | "preview" = "preview"; 88 | -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* iSponsorBlock Settings */ 2 | "Enabled" = "Enabled"; 3 | "RestartFooter" = "Restart YouTube for changes to take effect"; 4 | 5 | "Sponsor" = "Sponsor"; 6 | "Intermission/IntroAnimation" = "Intermission/Intro Animation"; 7 | "Intermission" = "Intermission"; 8 | "Endcards/Credits" = "Endcards/Credits"; 9 | "Outro" = "Outro"; 10 | "InteractionReminder" = "Interaction Reminder (Subscribe)"; 11 | "InteractionReminder_Subcribe/Like" = "Interaction Reminder (Subscribe/Like)"; 12 | "Interaction" = "Interaction"; 13 | "Unpaid/SelfPromotion" = "Unpaid/Self Promotion"; 14 | "SelfPromo" = "Self Promo"; 15 | "Non-MusicSection" = "Music: Non-Music Section"; 16 | "Non-Music" = "Non-Music"; 17 | "Preview" = "Preview"; 18 | "SponsorBlockUserID" = "SponsorBlock User ID"; 19 | "SponsorBlockAPIInstance" = "SponsorBlock API Instance"; 20 | 21 | "Disable" = "Disable"; 22 | "AutoSkip" = "Auto Skip"; 23 | "ShowInSeekBar" = "Show in Seek Bar"; 24 | "ManualSkip" = "Manual Skip"; 25 | "SetColorToShowInSeekBar" = "Set Color To Show in Seek Bar"; 26 | 27 | "UserID" = "User ID:"; 28 | "UserIDFooter" = "If you want to use a custom SponsorBlock user ID, you can enter it here. If you don't know what this is, leave it as default."; 29 | "API_URL" = "API URL:"; 30 | "APIFooter" = "If you want to use a custom SponsorBlock API instance, you can enter it here. If you don't know what this is, leave it as default. Example:https://sponsor.ajay.app/api"; 31 | "MinimumSegmentDuration" = "Set Minimum Segment Duration:"; 32 | "HowLongNoticeWillAppear" = "Set How Long Skip Notice Will Appear:"; 33 | "ShowSkipNotice" = "Show Skip Notice"; 34 | "ShowButtonsInPlayer" = "Show iSponsorBlock Buttons in Video Player"; 35 | "HideStartEndButtonInPlayer" = "Hide Start/End Button in Video Player"; 36 | "ShowModifiedTime" = "Show Modified Time in Seek Bar"; 37 | "AudioNotificationOnSkip" = "Audio Notification on Skip"; 38 | "AudioFooter" = "Unavailable in silent mode"; 39 | "EnableSkipCountTracking" = "Enable Skip Count Tracking"; 40 | "DonateOnVenmo" = "Donate on Venmo"; 41 | "DonateOnPayPal" = "Donate on PayPal"; 42 | 43 | /* Segments stuff */ 44 | "SegmentStartsNow" = "Segment Starts Now"; 45 | "SegmentEndsNow" = "Segment Ends Now"; 46 | "WhitelistChannel" = "Whitelist Channel"; 47 | "SegmentsInDatabase" = "There are already segments in the database:"; 48 | "YourSegments" = "Your Segments:"; 49 | "SubmitSegments" = "Submit Segments"; 50 | "SuccessfullySubmittedSegments" = "Successfully Submitted Segments"; 51 | "EndTimeLessThanStartTime" = "End Time That You Set Was Less Than the Start Time, Please Select a Time After"; //Example: ..., Please Select a Time After 10:15 52 | "UnfinishedSegments" = "You Have Unfinished Segments\n Please Add a Category and/or End Time to Your Segments"; 53 | "EditStartTime" = "Edit Start Time"; 54 | "EditStartTime_Desc" = "Edit Start Time: (ex. type 1:15)"; 55 | "EditEndTime" = "Edit End Time"; 56 | "EditEndTime_Desc" = "Edit End Time: (ex. type 1:15)"; 57 | "From" = "From"; // Time. Example: From 1:15 to 3:00. If you dont need it, just leave empty 58 | "to" = "to"; // Time. Example: From 1:15 to 3:00 59 | "EditCategory" = "Edit Category"; 60 | "EditSegment" = "Edit Segment"; 61 | "Edit" = "Edit"; 62 | "Error" = "Error"; 63 | "ErrorCode" = "Error Code"; 64 | "Success" = "Success"; 65 | "OK" = "OK"; 66 | "Cancel" = "Cancel"; 67 | "Delete" = "Delete"; 68 | "Upvote" = "Upvote"; 69 | "Downvote" = "Downvote"; 70 | "VoteToChangeCategory" = "Vote to Change Category"; 71 | "VoteOnSegment" = "Vote on Segment"; 72 | "SuccessfullyVoted" = "Successfully Voted"; 73 | "ErrorVoting" = "Error Voting"; 74 | 75 | /* Pop-ups*/ 76 | "ManuallySkipReminder" = "Manually Skip %@ segment\nfrom %ld:%02ld to %ld:%02ld?"; 77 | "Skip" = "Skip"; 78 | "SkippedSegment" = "Skipped %@ Segment"; 79 | "Unskip" = "Unskip"; 80 | 81 | /* Segments in pop-ups*/ 82 | "sponsor" = "sponsor"; 83 | "intro" = "intro"; 84 | "outro" = "outro"; 85 | "interaction" = "interaction"; 86 | "selfpromo" = "self promo"; 87 | "music_offtopic" = "non-music"; 88 | "preview" = "preview"; 89 | -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/es.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* iSponsorBlock Settings */ 2 | "Enabled" = "Activado"; 3 | "RestartFooter" = "Reinicia YouTube para que los cambios surtan efecto"; 4 | 5 | "Sponsor" = "Patrocinador"; 6 | "Intermission/IntroAnimation" = "Intermisión/Animación de introducción"; 7 | "Intermission" = "Intermisión"; 8 | "Endcards/Credits" = "Tarjetas Finales/Créditos"; 9 | "Outro" = "Final"; 10 | "InteractionReminder" = "Recordatorio de interacción (Suscribir)"; 11 | "InteractionReminder_Subcribe/Like" = "Recordatorio de interacción (Suscribir/Dar Me Gusta)"; 12 | "Interaction" = "Interacción"; 13 | "Unpaid/SelfPromotion" = "Promoción no remunerada/Auto promoción"; 14 | "SelfPromo" = "Auto promoción"; 15 | "Non-MusicSection" = "Música: sección sin música"; 16 | "Non-Music" = "Sin música"; 17 | "Preview" = "Preview"; 18 | "SponsorBlockUserID" = "ID usuario de SponsorBlock"; 19 | "SponsorBlockAPIInstance" = "Instancia API de SponsorBlock"; 20 | 21 | "Disable" = "No"; 22 | "AutoSkip" = "Auto"; 23 | "ShowInSeekBar" = "En la barra"; 24 | "ManualSkip" = "Manual"; 25 | "SetColorToShowInSeekBar" = "Establecer color para mostrar en la barra"; 26 | 27 | "UserID" = "ID de Usuario:"; 28 | "UserIDFooter" = "Si deseas usar un ID de usuario personalizado de SponsorBlock, puedes ingresarlo aquí. Si no sabes qué es esto, déjalo en su valor predeterminado."; 29 | "API_URL" = "URL de la API:"; 30 | "APIFooter" = "Si deseas usar una instancia de API personalizada de SponsorBlock, puedes ingresarla aquí. Si no sabes qué es esto, déjalo en su valor predeterminado. Ejemplo: https://sponsor.ajay.app/api"; 31 | "MinimumSegmentDuration" = "Duración mínima del segmento:"; 32 | "HowLongNoticeWillAppear" = "Duración del aviso de salto:"; 33 | "ShowSkipNotice" = "Mostrar aviso de salto"; 34 | "ShowButtonsInPlayer" = "Botones de iSponsorBlock en el reproductor"; 35 | "HideStartEndButtonInPlayer" = "Ocultar botón de Inicio/Fin en el reproductor"; 36 | "ShowModifiedTime" = "Mostrar tiempo modificado en la barra"; 37 | "AudioNotificationOnSkip" = "Notificación de Audio al saltar"; 38 | "AudioFooter" = "No disponible en modo silencioso"; 39 | "EnableSkipCountTracking" = "Habilitar el seguimiento de cuenta de saltos"; 40 | "DonateOnVenmo" = "Donar en Venmo"; 41 | "DonateOnPayPal" = "Donar en PayPal"; 42 | 43 | /* Segments stuff */ 44 | "SegmentStartsNow" = "Comenzar segmento"; 45 | "SegmentEndsNow" = "Terminar segmento"; 46 | "WhitelistChannel" = "Canal en lista blanca"; 47 | "SegmentsInDatabase" = "Ya existen segmentos en la base de datos:"; 48 | "YourSegments" = "Tus segmentos:"; 49 | "SubmitSegments" = "Enviar segmentos"; 50 | "SuccessfullySubmittedSegments" = "Segmentos enviados exitosamente"; 51 | "EndTimeLessThanStartTime" = "El Tiempo de finalización que estableciste es menor que el tiempo de inicio, por favor selecciona un tiempo después de"; 52 | "UnfinishedSegments" = "Tienes segmentos incompletos\n por favor agrega una categoría y/o tiempo de finalización a tus segmentos"; 53 | "EditStartTime" = "Editar tiempo de inicio"; 54 | "EditStartTime_Desc" = "Editar tiempo de inicio: (por ej. escribe 1:15)"; 55 | "EditEndTime" = "Editar tiempo de finalización"; 56 | "EditEndTime_Desc" = "Editar tiempo de finalización: (por ej. escribe 1:15)"; 57 | "From" = "Desde"; 58 | "to" = "hasta"; 59 | "EditCategory" = "Editar categoría"; 60 | "EditSegment" = "Editar segmento"; 61 | "Edit" = "Editar"; 62 | "Error" = "Error"; 63 | "ErrorCode" = "Código de error"; 64 | "Success" = "Éxito"; 65 | "OK" = "Aceptar"; 66 | "Cancel" = "Cancelar"; 67 | "Delete" = "Eliminar"; 68 | "Upvote" = "Voto positivo"; 69 | "Downvote" = "Voto negativo"; 70 | "VoteToChangeCategory" = "Votar para cambiar la categoría"; 71 | "VoteOnSegment" = "Votar en el segmento"; 72 | "SuccessfullyVoted" = "Votación exitosa"; 73 | "ErrorVoting" = "Error en la votación"; 74 | 75 | /* Pop-ups*/ 76 | "ManuallySkipReminder" = "¿Saltar manualmente el segmento %@\nde %ld:%02ld a %ld:%02ld?"; 77 | "Skip" = "Saltar"; 78 | "SkippedSegment" = "Segmento %@ Saltado"; 79 | "Unskip" = "Deshacer salto"; 80 | 81 | /* Segments in pop-ups*/ 82 | "sponsor" = "patrocinador"; 83 | "intro" = "introducción"; 84 | "outro" = "final"; 85 | "interaction" = "interacción"; 86 | "selfpromo" = "auto promoción"; 87 | "music_offtopic" = "no musical"; 88 | "preview" = "preview"; 89 | -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/id.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* iSponsorBlock Settings */ 2 | "Enabled" = "Diaktifkan"; 3 | "RestartFooter" = "Mulai ulang YouTube agar perubahan dapat diterapkan"; 4 | 5 | "Sponsor" = "Sponsor"; 6 | "Intermission/IntroAnimation" = "Animasi intermission / intro"; 7 | "Intermission" = "Intro"; 8 | "Endcards/Credits" = "Kartu akhir / kredit"; 9 | "Outro" = "Outro"; 10 | "InteractionReminder" = "Pengingat interaksi (subscribe)"; 11 | "InteractionReminder_Subcribe/Like" = "Pengingat interaksi (subscrib / suka)"; 12 | "Interaction" = "Interaksi"; 13 | "Unpaid/SelfPromotion" = "Promosi tidak dibayar / promosi diri sendiri"; 14 | "SelfPromo" = "Promosi diri sendiri"; 15 | "Non-MusicSection" = "Musik: bagian non-musik"; 16 | "Non-Music" = "Non-musik"; 17 | "Preview" = "Preview"; 18 | "SponsorBlockUserID" = "ID pengguna SponsorBlock"; 19 | "SponsorBlockAPIInstance" = "Instansi API SponsorBlock"; 20 | 21 | "Disable" = "Nonaktifkan"; 22 | "AutoSkip" = "Lewati otomatis"; 23 | "ShowInSeekBar" = "Tampilkan di seek bar"; 24 | "ManualSkip" = "Lewati manual"; 25 | "SetColorToShowInSeekBar" = "Atur warna untuk ditampilkan di seek bar"; 26 | 27 | "UserID" = "ID pengguna:"; 28 | "UserIDFooter" = "Jika anda ingin menggunakan ID pengguna SponsorBlock kustom, anda dapat memasukkannya di sini. Jika anda tidak tahu apa ini, biarkan sebagai default."; 29 | "API_URL" = "URL API:"; 30 | "APIFooter" = "Jika anda ingin menggunakan instansi API SponsorBlock kustom, anda dapat memasukkannya di sini. Jika anda tidak tahu apa ini, biarkan sebagai default. Contoh: https://sponsor.ajay.app/api"; 31 | "MinimumSegmentDuration" = "Atur durasi segmen minimum:"; 32 | "HowLongNoticeWillAppear" = "Atur berapa lama pemberitahuan lewati akan muncul:"; 33 | "ShowSkipNotice" = "Tampilkan pemberitahuan lewati"; 34 | "ShowButtonsInPlayer" = "Tampilkan tombol iSponsorBlock di pemutar video"; 35 | "HideStartEndButtonInPlayer" = "Sembunyikan tombol awal / akhir di pemutar video"; 36 | "ShowModifiedTime" = "Tampilkan waktu yang dimodifikasi di seek bar"; 37 | "AudioNotificationOnSkip" = "Notifikasi audio saat melewati"; 38 | "AudioFooter" = "Tidak tersedia dalam mode senyap"; 39 | "EnableSkipCountTracking" = "Aktifkan pelacakan jumlah lewati"; 40 | "DonateOnVenmo" = "Donasi di venmo"; 41 | "DonateOnPayPal" = "Donasi di paypal"; 42 | 43 | /* Segments stuff */ 44 | "SegmentStartsNow" = "Segmen dimulai sekarang"; 45 | "SegmentEndsNow" = "Segmen berakhir sekarang"; 46 | "WhitelistChannel" = "Daftar putih channel"; 47 | "SegmentsInDatabase" = "Sudah ada segmen dalam basis data:"; 48 | "YourSegments" = "Segmen anda:"; 49 | "SubmitSegments" = "Kirim segmen"; 50 | "SuccessfullySubmittedSegments" = "Segmen berhasil dikirim"; 51 | "EndTimeLessThanStartTime" = "Waktu akhir yang anda atur kurang dari waktu mulai, silakan pilih waktu setelah"; //Contoh: ..., silakan pilih waktu setelah 10:15 52 | "UnfinishedSegments" = "Anda memiliki segmen yang belum selesai\nSilakan tambahkan kategori dan/atau waktu akhir ke segmen anda"; 53 | "EditStartTime" = "Edit waktu mulai"; 54 | "EditStartTime_Desc" = "Edit waktu mulai: (mis. ketik 1:15)"; 55 | "EditEndTime" = "Edit waktu akhir"; 56 | "EditEndTime_Desc" = "Edit waktu akhir: (mis. ketik 1:15)"; 57 | "From" = "Dari"; // Waktu. Contoh: dari 1:15 hingga 3:00. Jika anda tidak membutuhkannya, biarkan kosong 58 | "to" = "ke"; // Waktu. Contoh: dari 1:15 hingga 3:00 59 | "EditCategory" = "Edit kategori"; 60 | "EditSegment" = "Edit segmen"; 61 | "Edit" = "Edit"; 62 | "Error" = "Kesalahan"; 63 | "ErrorCode" = "Kode kesalahan"; 64 | "Success" = "Berhasil"; 65 | "OK" = "OK"; 66 | "Cancel" = "Batal"; 67 | "Delete" = "Hapus"; 68 | "Upvote" = "Upvote"; 69 | "Downvote" = "Downvote"; 70 | "VoteToChangeCategory" = "Voting untuk mengubah kategori"; 71 | "VoteOnSegment" = "Voting pada segmen"; 72 | "SuccessfullyVoted" = "Berhasil memberikan voting"; 73 | "ErrorVoting" = "Kesalahan saat memberikan voting"; 74 | 75 | /* Pop-up */ 76 | "ManuallySkipReminder" = "Lewati %@ segmen\n dari %ld:%02ld ke %ld:%02ld?"; 77 | "Skip" = "Lewati"; 78 | "SkippedSegment" = "Segmen %@ dilewati"; 79 | "Unskip" = "Batalkan lewati"; 80 | 81 | /* Segments in pop-ups*/ 82 | "sponsor" = "sponsor"; 83 | "intro" = "intro"; 84 | "outro" = "outro"; 85 | "interaction" = "interaksi"; 86 | "selfpromo" = "promosi diri sendiri"; 87 | "music_offtopic" = "non-musik"; 88 | "preview" = "preview"; 89 | -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/ja.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* iSponsorBlock Settings */ 2 | "Enabled" = "有効"; 3 | "RestartFooter" = "変更を適用するためにYouTubeを再起動してください"; 4 | 5 | "Sponsor" = "スポンサー"; 6 | "Intermission/IntroAnimation" = "合間/導入アニメ"; 7 | "Intermission" = "合間"; 8 | "Endcards/Credits" = "終了画面/クレジット"; 9 | "Outro" = "終了画面"; 10 | "InteractionReminder" = "行動のお願い(登録)"; 11 | "InteractionReminder_Subcribe/Like" = "行動のお願い (高評価/チャンネル登録)"; 12 | "Interaction" = "行動のお願い"; 13 | "Unpaid/SelfPromotion" = "無報酬/自己宣伝"; 14 | "SelfPromo" = "自己宣伝"; 15 | "Non-MusicSection" = "音楽: 音楽以外のセクション"; 16 | "Non-Music" = "音楽以外"; 17 | "Preview" = "Preview"; 18 | "SponsorBlockUserID" = "SponsorBlockユーザーID"; 19 | "SponsorBlockAPIInstance" = "SponsorBlock APIインスタンス"; 20 | 21 | "Disable" = "無効"; 22 | "AutoSkip" = "自動スキップ"; 23 | "ShowInSeekBar" = "シークバーに表示"; 24 | "ManualSkip" = "手動スキップ"; 25 | "SetColorToShowInSeekBar" = "シークバーに表示する色を設定"; 26 | 27 | "UserID" = "ユーザーID:"; 28 | "UserIDFooter" = "カスタムされたSponsorBlockユーザーIDを使用する場合はここに入力します。わからない場合はデフォルトのままにしてください。"; 29 | "API_URL" = "API URL:"; 30 | "APIFooter" = "カスタムのSponsorBlock APIインスタンスを使用する場合はここに入力します。わからない場合はデフォルトのままにしてください。例:https://sponsor.ajay.app/api"; 31 | "MinimumSegmentDuration" = "最小セグメント期間を設定:"; 32 | "HowLongNoticeWillAppear" = "スキップ通知が表示される時間を設定:"; 33 | "ShowSkipNotice" = "スキップ通知を表示"; 34 | "ShowButtonsInPlayer" = "ビデオプレイヤーにiSponsorBlockボタンを表示"; 35 | "HideStartEndButtonInPlayer" = "ビデオプレイヤーの開始/終了ボタンを非表示"; 36 | "ShowModifiedTime" = "シークバーに修正時間を表示"; 37 | "AudioNotificationOnSkip" = "スキップ時の音声通知"; 38 | "AudioFooter" = "無音モードでは使用できません"; 39 | "EnableSkipCountTracking" = "スキップ回数のトラッキングを有効にする"; 40 | "DonateOnVenmo" = "Venmoで寄付する"; 41 | "DonateOnPayPal" = "PayPalで寄付する"; 42 | 43 | /* Segments stuff */ 44 | "SegmentStartsNow" = "セグメントが開始されました"; 45 | "SegmentEndsNow" = "セグメントが終了しました"; 46 | "WhitelistChannel" = "ホワイトリストチャンネル"; 47 | "SegmentsInDatabase" = "データベースにすでにセグメントがあります:"; 48 | "YourSegments" = "あなたのセグメント:"; 49 | "SubmitSegments" = "セグメントを登録"; 50 | "SuccessfullySubmittedSegments" = "セグメントは正常に登録されました"; 51 | "EndTimeLessThanStartTime" = "設定した終了時間が開始時間よりも前のため、それ以降の時間を選択してください"; //例: ..., 終了時間を10:15より後に設定してください 52 | "UnfinishedSegments" = "未完成のセグメントがあります。\nセグメントにカテゴリまたは終了時間を追加してください"; 53 | "EditStartTime" = "開始時間を編集"; 54 | "EditStartTime_Desc" = "開始時間を編集: (例. 1:15と入力してください)"; 55 | "EditEndTime" = "終了時間を編集"; 56 | "EditEndTime_Desc" = "終了時間を編集: (例. 1:15と入力してください)"; 57 | "From" = "From"; // 時間. 例: 1:15から3:00まで。必要ない場合は空白のままにしてください 58 | "to" = "to"; // 時間. 例: 1:15から3:00まで 59 | "EditCategory" = "カテゴリを編集"; 60 | "EditSegment" = "セグメントを編集"; 61 | "Edit" = "編集"; 62 | "Error" = "エラー"; 63 | "ErrorCode" = "エラーコード"; 64 | "Success" = "成功"; 65 | "OK" = "OK"; 66 | "Cancel" = "キャンセル"; 67 | "Delete" = "削除"; 68 | "Upvote" = "支持する"; 69 | "Downvote" = "反対する"; 70 | "VoteToChangeCategory" = "カテゴリの変更を投票"; 71 | "VoteOnSegment" = "セグメントに投票"; 72 | "SuccessfullyVoted" = "投票に成功しました"; 73 | "ErrorVoting" = "投票中にエラーが発生しました"; 74 | 75 | /* Pop-ups*/ 76 | "ManuallySkipReminder" = "%@セグメントを手動でスキップします。\n%ld:%02ldから%ld:%02ldまで?"; 77 | "Skip" = "スキップ"; 78 | "SkippedSegment" = "%@セグメントをスキップしました"; 79 | "Unskip" = "スキップを解除"; 80 | 81 | /* Segments in pop-ups*/ 82 | "sponsor" = "スポンサー"; 83 | "intro" = "合間/導入アニメ"; 84 | "outro" = "終了画面/クレジット"; 85 | "interaction" = "行動のお願い"; 86 | "selfpromo" = "自己宣伝"; 87 | "music_offtopic" = "音楽以外"; 88 | "preview" = "preview"; 89 | -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/ru.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* iSponsorBlock Settings */ 2 | "Enabled" = "Активировать iSponsorBlock"; 3 | "RestartFooter" = "Для применения настроек перезапустите YouTube"; 4 | 5 | "Sponsor" = "Спонсорская реклама"; 6 | "Intermission/IntroAnimation" = "Вступление/Интервалы"; 7 | "Intermission" = "Вступление"; 8 | "Endcards/Credits" = "Конечные заставки/Титры"; 9 | "Outro" = "Концовка"; 10 | "InteractionReminder" = "Взаимодействие (Подписаться)"; 11 | "InteractionReminder_Subcribe/Like" = "Взаимодействие (Лайк/Подписка)"; 12 | "Interaction" = "Взаимодействие"; 13 | "Unpaid/SelfPromotion" = "Самореклама"; 14 | "SelfPromo" = "Самореклама"; 15 | "Non-MusicSection" = "Музыка: Сегмент без музыки"; 16 | "Non-Music" = "Сегмент без музыки"; 17 | "Preview" = "Preview"; 18 | "SponsorBlockUserID" = "Идентификатор SponsorBlock"; 19 | "SponsorBlockAPIInstance" = "Используемый API"; 20 | 21 | "Disable" = "Выкл"; 22 | "AutoSkip" = "Перематывать"; 23 | "ShowInSeekBar" = "Игнорировать"; 24 | "ManualSkip" = "Вручную"; 25 | "SetColorToShowInSeekBar" = "Цвет сегмента, отображаемый в плеере"; 26 | 27 | "UserID" = "Ваш ID:"; 28 | "UserIDFooter" = "Если вы хотите использовать другой идентификатор пользователя SponsorBlock, то можете ввести его в окне выше. Если же вы не знаете, что это такое, то оставьте как есть."; 29 | "API_URL" = "Ссылка на API:"; 30 | "APIFooter" = "Если вы хотите использовать альтернативый API, то можете ввести его в окне выше. Если же вы не знаете, что это такое, то оставьте адрес по умолчанию. Адрес по умолчанию: https://sponsor.ajay.app/api"; 31 | "MinimumSegmentDuration" = "Минимальная длина рекламы:"; 32 | "HowLongNoticeWillAppear" = "Длительность уведомлений:"; 33 | "ShowSkipNotice" = "Отображать уведомления о перемотке"; 34 | "ShowButtonsInPlayer" = "Отображать кнопки твика в плеере"; 35 | "HideStartEndButtonInPlayer" = "Скрыть кнопку создания меток"; 36 | "ShowModifiedTime" = "Отображать сокращенное время в плеере"; 37 | "AudioNotificationOnSkip" = "Аудиоуведомление о перемотке"; 38 | "AudioFooter" = "Недоступно в беззвучном режиме"; 39 | "EnableSkipCountTracking" = "Включить подсчет пропущенной рекламы"; 40 | "DonateOnVenmo" = "Задонатить в Venmo"; 41 | "DonateOnPayPal" = "Задонатить в PayPal"; 42 | 43 | /* Segments stuff */ 44 | "SegmentStartsNow" = "Начало сегмента"; 45 | "SegmentEndsNow" = "Конец сегмента"; 46 | "WhitelistChannel" = "В белый список"; 47 | "SegmentsInDatabase" = "Сегменты в базе данных:"; 48 | "YourSegments" = "Ваши сегменты:"; 49 | "SubmitSegments" = "Отправить"; 50 | "SuccessfullySubmittedSegments" = "Успешно отправлено"; 51 | "EndTimeLessThanStartTime" = "Выбранное вами время конца сегмента находится раньше начала сегмента. Выберите время после"; //Example: ..., Please Select a Time After 10:15 52 | "UnfinishedSegments" = "Имеются неполноценные сегменты.\nУбедитесь, что вы выбрали категорию и/или время окончания сегмента"; 53 | "EditStartTime" = "Изменить начало сегмента"; 54 | "EditStartTime_Desc" = "Время начала: (Например: 1:15)"; 55 | "EditEndTime" = "Изменить окончание сегмента"; 56 | "EditEndTime_Desc" = "Время окончания: (Например: 1:15)"; 57 | "From" = "С"; // Time. Example: From 1:15 to 3:00. If you dont need it, just leave empty 58 | "to" = "по"; // Time. Example: From 1:15 to 3:00 59 | "EditCategory" = "Изменить категорию"; 60 | "EditSegment" = "Изменить сегмент"; 61 | "Edit" = "Изменить"; 62 | "Error" = "Ошибка"; 63 | "ErrorCode" = "Код ошибки"; 64 | "Success" = "Готово"; 65 | "OK" = "OK"; 66 | "Cancel" = "Отмена"; 67 | "Delete" = "Удалить"; 68 | "Upvote" = "Проголосовать за"; 69 | "Downvote" = "Проголосовать против"; 70 | "VoteToChangeCategory" = "Проголосовать за смену категории"; 71 | "VoteOnSegment" = "Проголосовать за сегмент"; 72 | "SuccessfullyVoted" = "Голос отправлен"; 73 | "ErrorVoting" = "Ошибка голосования"; 74 | 75 | /* Pop-ups*/ 76 | "ManuallySkipReminder" = "Перемотать %@ с %ld:%02ld до %ld:%02ld?"; 77 | "Skip" = "Да"; 78 | "SkippedSegment" = "Перемотан\n%@"; 79 | "Unskip" = "Отмена"; 80 | 81 | /* Segments in pop-ups*/ 82 | "sponsor" = "спонсорский\nсегмент"; 83 | "intro" = "сегмент со\nвступлением"; 84 | "outro" = "сегмент\nс титрами"; 85 | "interaction" = "сегмент со\nвзаимодействием"; 86 | "selfpromo" = "сегмент с\nсаморекламой"; 87 | "music_offtopic" = "сегмент\nбез музыки"; 88 | "preview" = "preview"; 89 | -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/sponsorblockend-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Galactic-Dev/iSponsorBlock/3e4157c2a84576d175fc73ae422927e3d2531055/layout/Library/Application Support/iSponsorBlock.bundle/sponsorblockend-20@2x.png -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/sponsorblocksettings-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Galactic-Dev/iSponsorBlock/3e4157c2a84576d175fc73ae422927e3d2531055/layout/Library/Application Support/iSponsorBlock.bundle/sponsorblocksettings-20@2x.png -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/sponsorblockstart-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Galactic-Dev/iSponsorBlock/3e4157c2a84576d175fc73ae422927e3d2531055/layout/Library/Application Support/iSponsorBlock.bundle/sponsorblockstart-20@2x.png -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/tr.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* iSponsorBlock Settings */ 2 | "Enabled" = "Açık"; 3 | "RestartFooter" = "YT'u yeniden başlat"; 4 | 5 | "Sponsor" = "Sponsor"; 6 | "Intermission/IntroAnimation" = "Ara/Giriş Anim."; 7 | "Intermission" = "Ara"; 8 | "Endcards/Credits" = "Bitiş Kart./Jenerik"; 9 | "Outro" = "Bitiş"; 10 | "InteractionReminder" = "Etk. Hatırlat (Abone Ol)"; 11 | "InteractionReminder_Subcribe/Like" = "Etk. Hatırlat (Abone/Beğen)"; 12 | "Interaction" = "Etk."; 13 | "Unpaid/SelfPromotion" = "Ücretsiz/Kendi Rek."; 14 | "SelfPromo" = "Kendi Rek."; 15 | "Non-MusicSection" = "Müzik Dışı Bölüm"; 16 | "Non-Music" = "Müzik Dışı"; 17 | "Preview" = "Preview"; 18 | "SponsorBlockUserID" = "SponsorBlock Kullanıcı Adı:"; 19 | "SponsorBlockAPIInstance" = "SponsorBlock API Örneği"; 20 | 21 | "Disable" = "Kapat"; 22 | "AutoSkip" = "Oto. Geç"; 23 | "ShowInSeekBar" = "İlrm Çub. Göster"; 24 | "ManualSkip" = "Elle Geç"; 25 | "SetColorToShowInSeekBar" = "İlrm Çub. Renk Seç"; 26 | 27 | "UserID" = "Kullanıcı Adı:"; 28 | "UserIDFooter" = "Özel SB kullanıcı adı istiyorsan buraya gir. Bilmiyorsan varsayılan bırak."; 29 | "API_URL" = "API Bağlantı:"; 30 | "APIFooter" = "Özel SB API için gir. Bilmiyorsan varsayılan bırak. Örnek: https://sponsor.ajay.app/api"; 31 | "MinimumSegmentDuration" = "Min. Bölüm Süresi Ayarla:"; 32 | "HowLongNoticeWillAppear" = "Atlama Uyarı Süresi Ayarla:"; 33 | "ShowSkipNotice" = "Atlama Uyarısını Göster"; 34 | "ShowButtonsInPlayer" = "iSB Düğm. Oynatıcıda Göster"; 35 | "HideStartEndButtonInPlayer" = "Oynatıcıda Başlat/Bitiş Düğm. Gizle"; 36 | "ShowModifiedTime" = "Değ. Zamanını Göster"; 37 | "AudioNotificationOnSkip" = "Geçiş Snrsı Sesli Bild."; 38 | "AudioFooter" = "Sessiz modda yok"; 39 | "EnableSkipCountTracking" = "Geçiş Say. Takibini Aç"; 40 | "DonateOnVenmo" = "Venmo'dan bağış yap"; 41 | "DonateOnPayPal" = "PayPal'dan bağış yap"; 42 | 43 | /* Segments stuff */ 44 | "SegmentStartsNow" = "Bölüm Başlıyor"; 45 | "SegmentEndsNow" = "Bölüm Bitiyor"; 46 | "WhitelistChannel" = "Kanala İzin Ver"; 47 | "SegmentsInDatabase" = "Veritabanında Bölüm Var:"; 48 | "YourSegments" = "Bölümler:"; 49 | "SubmitSegments" = "Bölüm Gönder"; 50 | "SuccessfullySubmittedSegments" = "Başarıyla Gönderildi"; 51 | "EndTimeLessThanStartTime" = "Bitiş Başlangıçtan Önce, Snr Düzelt"; //Örnek: ..., Lütfen 10:15'ten Snr olan Bir Zaman Seç. 52 | "UnfinishedSegments" = "Tamamlanmamış Bölümler. Kategori/Bitiş Zamanı Ekle"; 53 | "EditStartTime" = "Başlangıç Zamanı Düzenle"; 54 | "EditStartTime_Desc" = "Başlangıç Zamanı Düzenle: (ör. 1:15 yaz)"; 55 | "EditEndTime" = "Bitiş Zamanı Düzenle"; 56 | "EditEndTime_Desc" = "Bitiş Zamanı Düzenle: (ör. 1:15 yaz)"; 57 | "From" = "Başlangıç"; // Time. Example: From 1:15 to 3:00. If you dont need it, just leave empty 58 | "to" = "Bitiş"; // Time. Example: From 1:15 to 3:00 59 | "EditCategory" = "Kategori Düzenle"; 60 | "EditSegment" = "Bölüm Düzenle"; 61 | "Edit" = "Düzenle"; 62 | "Error" = "Hata"; 63 | "ErrorCode" = "Hata Kodu"; 64 | "Success" = "Başarılı"; 65 | "OK" = "Tamam"; 66 | "Cancel" = "İptal"; 67 | "Delete" = "Sil"; 68 | "Upvote" = "Olumlu Oy"; 69 | "Downvote" = "Olumsuz Oy"; 70 | "VoteToChangeCategory" = "Kategori Değ. Oy Ver"; 71 | "VoteOnSegment" = "Bölüme Oy Ver"; 72 | "SuccessfullyVoted" = "Oy Verildi"; 73 | "ErrorVoting" = "Oylama Hatası"; 74 | 75 | /* Pop-ups*/ 76 | "ManuallySkipReminder" = "Elle Geç %@ Bölüm %ld:%02ld 'den %ld:%02ld? 'e"; 77 | "Skip" = "Geç"; 78 | "SkippedSegment" = "Bölüm %@ Geçildi"; 79 | "Unskip" = "Geçme"; 80 | 81 | /* Segments in pop-ups*/ 82 | "sponsor" = "Sponsor"; 83 | "intro" = "Giriş"; 84 | "outro" = "Bitiş"; 85 | "interaction" = "Etk."; 86 | "selfpromo" = "Kendi Rek."; 87 | "music_offtopic" = "Müzik Dışı"; 88 | "preview" = "preview"; 89 | -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/vi.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* iSponsorBlock Settings */ 2 | "Enabled" = "Bật"; 3 | "RestartFooter" = "Khởi động lại YouTube để các thay đổi có hiệu lực"; 4 | 5 | "Sponsor" = "Người tài trợ"; 6 | "Intermission/IntroAnimation" = "Tạm dừng/Giới thiệu"; 7 | "Intermission" = "Tạm ngừng"; 8 | "Endcards/Credits" = "Màn hình kết thúc/Danh đề"; 9 | "Outro" = "Kết thúc"; 10 | "InteractionReminder" = "Nhắc tương tác (Đăng ký)"; 11 | "InteractionReminder_Subcribe/Like" = "Nhắc tương tác (Đăng ký/Thích)"; 12 | "Interaction" = "Tương tác"; 13 | "Unpaid/SelfPromotion" = "Quảng cáo không trả phí/Tự quảng cáo"; 14 | "SelfPromo" = "Tự giới thiệu"; 15 | "Non-MusicSection" = "Nhạc: Phần không nhạc"; 16 | "Non-Music" = "Không có nhạc"; 17 | "Preview" = "Preview"; 18 | "SponsorBlockUserID" = "ID người dùng SponsorBlock"; 19 | "SponsorBlockAPIInstance" = "Phiên bản API SponsorBlock"; 20 | 21 | "Disable" = "Tắt"; 22 | "AutoSkip" = "Tự động"; 23 | "ShowInSeekBar" = "Hiển thị ở thanh tua"; 24 | "ManualSkip" = "Thủ công"; 25 | "SetColorToShowInSeekBar" = "Chọn màu hiển thị (thanh tua)"; 26 | 27 | "UserID" = "ID Người dùng:"; 28 | "UserIDFooter" = "Nếu bạn muốn sử dụng một ID người dùng SponsorBlock tùy chỉnh, bạn có thể nhập nó ở đây. Nếu bạn không biết đây là gì, hãy để mặc định."; 29 | "API_URL" = "Đường dẫn API:"; 30 | "APIFooter" = "Nếu bạn muốn sử dụng một phiên bản API SponsorBlock tùy chỉnh, bạn có thể nhập nó ở đây. Nếu bạn không biết đây là gì, hãy để mặc định. Ví dụ: https://sponsor.ajay.app/api"; 31 | "MinimumSegmentDuration" = "Thời gian phân đoạn tối thiểu:"; 32 | "HowLongNoticeWillAppear" = "Thời gian hiển thị thông báo:"; 33 | "ShowSkipNotice" = "Hiển thị thông báo bỏ qua"; 34 | "ShowButtonsInPlayer" = "Hiển thị nút iSponsorBlock trong trình phát video"; 35 | "HideStartEndButtonInPlayer" = "Ẩn nút Bắt đầu/Kết thúc trong trình phát video"; 36 | "ShowModifiedTime" = "Hiển thị thời gian đã chỉnh sửa ở thanh tua"; 37 | "AudioNotificationOnSkip" = "Phát âm thanh khi bỏ qua"; 38 | "AudioFooter" = "Không khả dụng trong chế độ im lặng"; 39 | "EnableSkipCountTracking" = "Bật tính năng theo dõi số phân đoạn đã bỏ qua"; 40 | "DonateOnVenmo" = "Ủng hộ qua Venmo"; 41 | "DonateOnPayPal" = "Ủng hộ qua PayPal"; 42 | 43 | /* Segments stuff */ 44 | "SegmentStartsNow" = "Bắt đầu phân đoạn"; 45 | "SegmentEndsNow" = "Dừng phân đoạn"; 46 | "WhitelistChannel" = "Đưa kênh vào danh sách không chặn"; 47 | "SegmentsInDatabase" = "Phân đoạn đã có trong cơ sở dữ liệu:"; 48 | "YourSegments" = "Phân đoạn của bạn:"; 49 | "SubmitSegments" = "Gửi phân đoạn"; 50 | "SuccessfullySubmittedSegments" = "Gửi thành công"; 51 | "EndTimeLessThanStartTime" = "Thời gian kết thúc nhỏ hơn thời gian bắt đầu. Vui lòng chọn lại."; 52 | "UnfinishedSegments" = "Bạn có các phân đoạn chưa hoàn thành\n Vui lòng thêm danh mục và/hoặc thời gian kết thúc cho các phân đoạn của bạn"; 53 | "EditStartTime" = "Sửa thời gian bắt đầu"; 54 | "EditStartTime_Desc" = "Chỉnh sửa thời gian bắt đầu: (ví dụ: nhập 1:15)"; 55 | "EditEndTime" = "Sửa thời gian kết thúc"; 56 | "EditEndTime_Desc" = "Chỉnh sửa thời gian kết thúc: (ví dụ: nhập 1:15)"; 57 | "From" = "Từ"; 58 | "to" = "đến"; 59 | "EditCategory" = "Sửa danh mục"; 60 | "EditSegment" = "Sửa phân đoạn"; 61 | "Edit" = "Sửa"; 62 | "Error" = "Lỗi"; 63 | "ErrorCode" = "Mã lỗi"; 64 | "Success" = "Thành công"; 65 | "OK" = "Ok"; 66 | "Cancel" = "Hủy"; 67 | "Delete" = "Xóa"; 68 | "Upvote" = "Bình chọn"; 69 | "Downvote" = "Phản đối"; 70 | "VoteToChangeCategory" = "Bỏ phiếu để thay đổi danh mục"; 71 | "VoteOnSegment" = "Bỏ phiếu trên phân đoạn"; 72 | "SuccessfullyVoted" = "Đã bỏ phiếu thành công"; 73 | "ErrorVoting" = "Lỗi khi bỏ phiếu"; 74 | 75 | /* Pop-ups */ 76 | "ManuallySkipReminder" = "Bỏ qua phân đoạn %@ từ %ld:%02ld đến %ld:%02ld?"; 77 | "Skip" = "Bỏ qua"; 78 | "SkippedSegment" = "Đã bỏ qua phân đoạn %@"; 79 | "Unskip" = "Hủy bỏ qua"; 80 | 81 | /* Segments in pop-ups */ 82 | "sponsor" = "người tài trợ"; 83 | "intro" = "mở đầu"; 84 | "outro" = "kết thúc"; 85 | "interaction" = "tương tác"; 86 | "selfpromo" = "tự giới thiệu"; 87 | "music_offtopic" = "không có nhạc"; 88 | "preview" = "preview"; 89 | -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/zh-TW.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* iSponsorBlock Settings */ 2 | "Enabled" = "啟用"; 3 | "RestartFooter" = "重新啟動Youtube以套用更變"; 4 | 5 | "Sponsor" = "贊助商"; 6 | "Intermission/IntroAnimation" = "中場/開場動畫"; 7 | "Intermission" = "中場"; 8 | "Endcards/Credits" = "結尾資訊/致謝"; 9 | "Outro" = "其他"; 10 | "InteractionReminder" = "訂閱推廣"; 11 | "InteractionReminder_Subcribe/Like" = "訂閱/按讚推廣"; 12 | "Interaction" = "推廣"; 13 | "Unpaid/SelfPromotion" = "免費/自薦"; 14 | "SelfPromo" = "自薦"; 15 | "Non-MusicSection" = "音樂: 非音樂片段"; 16 | "Non-Music" = "非音樂片段"; 17 | "Preview" = "Preview"; 18 | "SponsorBlockUserID" = "SponsorBlock 使用者 ID"; 19 | "SponsorBlockAPIInstance" = "SponsorBlock API 範例"; 20 | 21 | "Disable" = "停用"; 22 | "AutoSkip" = "自動跳過"; 23 | "ShowInSeekBar" = "顯示在進度欄"; 24 | "ManualSkip" = "手動跳過"; 25 | "SetColorToShowInSeekBar" = "設定在進度欄顯示的顏色"; 26 | 27 | "UserID" = "使用者 ID:"; 28 | "UserIDFooter" = "如果您想使用自訂的 SponsorBlock 使用者 ID, 您可以在此輸入. 如果您不清楚這是什麼, 請維持預設值."; 29 | "API_URL" = "API 超連結:"; 30 | "APIFooter" = "如果您想使用自訂的 SponsorBlock API, 您可以在此輸入. 如果您不清楚這是什麼, 請維持預設值. 範例:https://sponsor.ajay.app/api"; 31 | "MinimumSegmentDuration" = "設定片段最小長度:"; 32 | "HowLongNoticeWillAppear" = "設定跳過通知顯示的時間:"; 33 | "ShowSkipNotice" = "顯示跳過通知"; 34 | "ShowButtonsInPlayer" = "在影片播放器中顯示 iSponsorBlock 按鈕"; 35 | "HideStartEndButtonInPlayer" = "在影片播放器中隱藏 開始/結束 按鈕"; 36 | "ShowModifiedTime" = "在進度欄顯示修改時間"; 37 | "AudioNotificationOnSkip" = "在跳過時使用音效提示"; 38 | "AudioFooter" = "在靜音模式下沒有效果"; 39 | "EnableSkipCountTracking" = "啟用追蹤跳過計數器"; 40 | "DonateOnVenmo" = "透過 Venmo 贊助"; 41 | "DonateOnPayPal" = "透過 PayPal 贊助"; 42 | 43 | /* Segments stuff */ 44 | "SegmentStartsNow" = "片段現在開始"; 45 | "SegmentEndsNow" = "片段現在結束"; 46 | "WhitelistChannel" = "頻道白名單"; 47 | "SegmentsInDatabase" = "資料庫中已存在片段:"; 48 | "YourSegments" = "您的片段:"; 49 | "SubmitSegments" = "送出片段"; 50 | "SuccessfullySubmittedSegments" = "成功送出片段"; 51 | "EndTimeLessThanStartTime" = "您設定的結束時間小於開始時間, 請選擇大於的時間"; //Example: ..., Please Select a Time After 10:15 52 | "UnfinishedSegments" = "您尚未完成片段\n 請新增分類 並/或 結束時間至您的片段"; 53 | "EditStartTime" = "編輯開始時間"; 54 | "EditStartTime_Desc" = "編輯開始時間: (範例. 輸入 1:15)"; 55 | "EditEndTime" = "編輯結束時間"; 56 | "EditEndTime_Desc" = "編輯結束時間: (範例. 輸入 1:15)"; 57 | "From" = "從"; // Time. Example: From 1:15 to 3:00. If you dont need it, just leave empty 58 | "to" = "到"; // Time. Example: From 1:15 to 3:00 59 | "EditCategory" = "編輯分類"; 60 | "EditSegment" = "編輯片段"; 61 | "Edit" = "編輯"; 62 | "Error" = "錯誤"; 63 | "ErrorCode" = "錯誤碼"; 64 | "Success" = "成功"; 65 | "OK" = "好"; 66 | "Cancel" = "取消"; 67 | "Delete" = "刪除"; 68 | "Upvote" = "讚"; 69 | "Downvote" = "爛"; 70 | "VoteToChangeCategory" = "投票來更改分類"; 71 | "VoteOnSegment" = "對片段進行投票"; 72 | "SuccessfullyVoted" = "投票成功"; 73 | "ErrorVoting" = "投票錯誤"; 74 | 75 | /* Pop-ups*/ 76 | "ManuallySkipReminder" = "手動跳過 %@ 片段\n從 %ld:%02ld 到 %ld:%02ld?"; 77 | "Skip" = "跳過"; 78 | "SkippedSegment" = "已跳過 %@ 片段"; 79 | "Unskip" = "取消跳過"; 80 | 81 | /* Segments in pop-ups*/ 82 | "sponsor" = "贊助商"; 83 | "intro" = "開場"; 84 | "outro" = "結尾"; 85 | "interaction" = "推廣頻道"; 86 | "selfpromo" = "自薦"; 87 | "music_offtopic" = "非音樂"; 88 | "preview" = "preview"; -------------------------------------------------------------------------------- /layout/Library/Application Support/iSponsorBlock.bundle/zh_cn.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* iSponsorBlock Settings */ 2 | "Enabled" = "启用"; 3 | "RestartFooter" = "请重启 YouTube 来应用更改。"; 4 | 5 | "Sponsor" = "赞助商广告"; 6 | "Intermission/IntroAnimation" = "中场/开场动画"; 7 | "Intermission" = "过场"; 8 | "Endcards/Credits" = "片尾卡片/名单"; 9 | "Outro" = "片尾"; 10 | "InteractionReminder" = "观众互动(订阅)"; 11 | "InteractionReminder_Subcribe/Like" = "观众互动(订阅/点赞)"; 12 | "Interaction" = "互动"; 13 | "Unpaid/SelfPromotion" = "无偿/自我宣传"; 14 | "SelfPromo" = "自我宣传"; 15 | "Non-MusicSection" = "音乐视频:非音乐时段"; 16 | "Non-Music" = "非音乐时段"; 17 | "Preview" = "Preview"; 18 | "SponsorBlockUserID" = "SponsorBlock 用户 ID"; 19 | "SponsorBlockAPIInstance" = "SponsorBlock API"; 20 | 21 | "Disable" = "不跳过"; 22 | "AutoSkip" = "自动跳过"; 23 | "ShowInSeekBar" = "在进度条中显示"; 24 | "ManualSkip" = "手动跳过"; 25 | "SetColorToShowInSeekBar" = "进度条指示颜色"; 26 | 27 | "UserID" = "用户 ID:"; 28 | "UserIDFooter" = "请在此输入您想使用的自定义 SponsorBlock 用户 ID。如果您不熟悉此功能,请使用默认设置。"; 29 | "API_URL" = "API 地址:"; 30 | "APIFooter" = "请在此输入您想使用的自定义 SponsorBlock API 地址。如果您不熟悉此功能,请使用默认设置。示例:https://sponsor.ajay.app/api。"; 31 | "MinimumSegmentDuration" = "最短可跳过时段时长(秒):"; 32 | "HowLongNoticeWillAppear" = "跳过提示窗显示时长(秒):"; 33 | "ShowSkipNotice" = "跳过提示窗"; 34 | "ShowButtonsInPlayer" = "在视频播放器中显示 iSponsorBlock 按钮"; 35 | "HideStartEndButtonInPlayer" = "隐藏视频播放器中的时段开始/结束按钮"; 36 | "ShowModifiedTime" = "显示缩短后视频时长"; 37 | "AudioNotificationOnSkip" = "跳过提示音"; 38 | "AudioFooter" = "静音模式下不可用。"; 39 | "EnableSkipCountTracking" = "记录已跳过次数"; 40 | "DonateOnVenmo" = "在 Venmo 上捐助"; 41 | "DonateOnPayPal" = "在 PayPal 上捐助"; 42 | 43 | /* Segments stuff */ 44 | "SegmentStartsNow" = "时段开始"; 45 | "SegmentEndsNow" = "时段结束"; 46 | "WhitelistChannel" = "本频道不跳过"; 47 | "SegmentsInDatabase" = "以下时段已在数据库中:"; 48 | "YourSegments" = "您的时段:"; 49 | "SubmitSegments" = "提交时段"; 50 | "SuccessfullySubmittedSegments" = "提交时段成功"; 51 | "EndTimeLessThanStartTime" = "结束时间不可设置在开始时间之前。请将结束时间调整到此时间戳之后:"; //Example: ..., Please Select a Time After 10:15 52 | "UnfinishedSegments" = "您有尚未完成的时段,\n请确认是否已设置分类和结束时间。"; 53 | "EditStartTime" = "调整开始时间"; 54 | "EditStartTime_Desc" = "请输入开始时间(示例:1:15)"; 55 | "EditEndTime" = "调整结束时间"; 56 | "EditEndTime_Desc" = "请输入结束时间(示例:1:15)"; 57 | "From" = ""; // Time. Example: From 1:15 to 3:00. If you dont need it, just leave empty 58 | "to" = "至"; // Time. Example: From 1:15 to 3:00 59 | "EditCategory" = "更改分类"; 60 | "EditSegment" = "编辑时段"; 61 | "Edit" = "编辑"; 62 | "Error" = "错误"; 63 | "ErrorCode" = "错误代码"; 64 | "Success" = "成功"; 65 | "OK" = "确定"; 66 | "Cancel" = "取消"; 67 | "Delete" = "删除"; 68 | "Upvote" = "好评"; 69 | "Downvote" = "差评"; 70 | "VoteToChangeCategory" = "投票纠正分类"; 71 | "VoteOnSegment" = "为时段评分"; 72 | "SuccessfullyVoted" = "投票成功"; 73 | "ErrorVoting" = "投票出错"; 74 | 75 | /* Pop-ups*/ 76 | "ManuallySkipReminder" = "点击跳过%@时段:%ld:%02ld 至 %ld:%02ld"; 77 | "Skip" = "跳过"; 78 | "SkippedSegment" = "已自动跳过%@时段"; 79 | "Unskip" = "撤消跳过"; 80 | 81 | /* Segments in pop-ups*/ 82 | "sponsor" = "广告"; 83 | "intro" = "开场"; 84 | "outro" = "片尾"; 85 | "interaction" = "互动"; 86 | "selfpromo" = "自我宣传"; 87 | "music_offtopic" = "非音乐"; 88 | "preview" = "preview"; 89 | --------------------------------------------------------------------------------