How to Integrate SponsorBlock with YTLite: A Complete Guide for iOS Developers

YTLite ships with built-in SponsorBlock integration that automatically skips sponsored segments in YouTube videos—no additional installation required.

SponsorBlock is a community-driven project that crowdsources timestamps for non-content segments in YouTube videos. In dayanch96/YTLite, this functionality is implemented natively through a toggleable feature that fetches segment data from the SponsorBlock API and renders skip markers directly in the iOS YouTube player. This guide walks through the architecture, configuration options, and code-level integration points.

How SponsorBlock Works in YTLite

When Enable SponsorBlock is activated, YTLite performs four coordinated operations:

  1. UI Injection: Adds a SponsorBlock button to the YTActionSheet overlay via hooks in Settings.x
  2. API Fetching: Queries https://sponsor.ajay.app/api/skipSegments for the current video ID
  3. Visual Markers: Draws colored progress-bar segments for each detected category (sponsor, intro, outro, etc.)
  4. Automatic Skipping: Seeks past segments when playback reaches their start time or when the user taps the overlay button

The entire system is gated by a single user default flag: EnableSponsorBlock.

SponsorBlock Architecture and Key Files

Component File Path Purpose
Settings UI & Button Injection Settings.x Adds toggle to YTLite section and injects player overlay button
User Defaults Storage Utils/YTLUserDefaults.m Persists EnableSponsorBlock flag across app launches
Localized Strings layout/Library/Application Support/YTLite.bundle/*/Localizable.strings Provides UI labels (EnableSponsorBlock, SbPlayerButtonDesc) and segment color mappings
Feature Metadata Resources/depiction.json Documents SponsorBlock capability for package managers

Enabling SponsorBlock in YTLite

Method 1: Through the Settings UI

  1. Open the YouTube app on your iOS device
  2. Navigate to Settings → YTLite (the injected section)
  3. Toggle "Enable SponsorBlock"
  4. The change persists immediately; the next video will show segment markers

The toggle label and description are drawn from Localizable.strings using the keys EnableSponsorBlock and EnableSponsorBlockDesc.

Method 2: Programmatic Toggle via Objective-C

For developers building custom tweaks or automation scripts, YTLite exposes macro helpers to manipulate the flag directly:

#import "YTLUserDefaults.h"

// Enable SponsorBlock
ytlSetBool(YES, @"EnableSponsorBlock");

// Verify current state
BOOL isEnabled = ytlBool(@"EnableSponsorBlock");
NSLog(@"SponsorBlock active: %@", isEnabled ? @"YES" : @"NO");

// Disable SponsorBlock
ytlSetBool(NO, @"EnableSponsorBlock");

These macros wrap NSUserDefaults with the suite identifier com.dvntm.ytlite, ensuring settings persist across app sessions.

Understanding Segment Categories and Colors

SponsorBlock categorizes non-content segments into types. YTLite maps these to localized labels and visual colors:

Category Key Typical Purpose Localization Key
sponsor Paid promotions, product placements sb_sponsor
intro Introductory sequences sb_intro
outro End credits, outro sequences sb_outro
interaction Reminder to like, subscribe, etc. sb_interaction

Color values are embedded in the compiled binary. The localization files in layout/Library/Application Support/YTLite.bundle/*/Localizable.strings only provide the display names for these segment types.

Extending SponsorBlock Integration

Developers can add new category toggles or custom UI elements by modifying Settings.x and YTLUserDefaults.m.

Adding a New Category Toggle

To expose the selfpromo category (channel owner promotions):

// In Utils/YTLUserDefaults.m, add to -registerDefaults:
@{@"skipSelfPromo": @YES}

// In Settings.x, add to the player section:
YTSettingsSectionItem *selfPromoToggle = [self switchWithTitle:@"SkipSelfPromo"
                                                          key:@"skipSelfPromo"];
[sectionItems addObject:selfPromoToggle];

Add corresponding entries to each Localizable.strings file:

"SkipSelfPromo" = "Skip Self-Promotions";
"SkipSelfPromoDesc" = "Skip segments where the creator promotes their own products";

Creating a Custom Skip Button

For advanced use cases, trigger segment skipping programmatically:

// Skip to end of current sponsor segment
NSDictionary *currentSegment = /* obtain from API response */;
double skipTarget = [currentSegment[@"end"] doubleValue];

// Seek playback
[[%c(YTPlayer) sharedInstance] seekToTime:skipTarget];

Summary

  • YTLite includes native SponsorBlock integration—no separate app or extension needed
  • Enable the feature via Settings → YTLite → Enable SponsorBlock, or programmatically with ytlSetBool(YES, @"EnableSponsorBlock")
  • Key files: Settings.x (UI), Utils/YTLUserDefaults.m (persistence), Localizable.strings (labels)
  • Extensible architecture: Add new category toggles by registering defaults and creating settings items
  • Segment data comes from the public SponsorBlock API at sponsor.ajay.app

Frequently Asked Questions

Does YTLite require a separate SponsorBlock installation?

No. YTLite bundles SponsorBlock functionality directly into the tweak. The feature communicates with the public SponsorBlock API—no additional apps, extensions, or background processes are required on your iOS device.

Where are SponsorBlock settings stored?

Settings persist in the com.dvntm.ytlite NSUserDefaults suite. The primary flag EnableSponsorBlock is read and written through the ytlBool and ytlSetBool macros defined in Utils/YTLUserDefaults.m. These values survive app restarts and iOS reboots.

Can I customize which segment types get skipped?

Partially. The current YTLite release exposes a master toggle for SponsorBlock. However, the architecture supports granular category toggles—developers can extend Settings.x to add individual switches for sponsor, intro, outro, interaction, and other categories by following the pattern in section 5 of this guide.

Why don't I see colored markers on some videos?

Segment markers appear only when: (1) SponsorBlock is enabled in YTLite settings, (2) the video has submitted segments in the SponsorBlock database, and (3) the API request succeeds. Some videos lack community-submitted data, and API rate limits or network issues can occasionally prevent marker rendering.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →