tizenportal

Adblock Bundle

Version: 1.0.0 (Optimized)
Size: 30.4KB JS + 7.6KB CSS = 38KB total
Purpose: Lightweight ad blocking for TV browsing

Overview

The Adblock bundle provides multi-layered ad blocking for general web browsing on Tizen TVs. It’s designed as a best-effort generic blocker, primarily for news sites, blogs, and other ad-heavy content.

Note: Site-specific bundles (Audiobookshelf, etc.) typically don’t need ad blocking as they serve content from your own servers.

Features

1. Multi-Layered Blocking

The bundle uses 5 complementary approaches:

  1. CSS-Based Hiding (143+ selectors)
    • Immediate, lightweight
    • Hides common ad containers by class/ID
    • Applied instantly on page load
  2. DOM Removal
    • Deletes matched elements from the page
    • Cleans up space left by hidden ads
    • Runs periodically and on DOM changes
  3. Request Interception
    • Blocks XHR/fetch to known ad domains
    • Prevents ads from loading at all
    • Saves bandwidth
  4. DOM Insertion Hooks
    • Intercepts appendChild/insertBefore/replaceChild
    • Optimized: Only checks SCRIPT and IFRAME nodes
    • Blocks ads before they reach the DOM
  5. MutationObserver
    • Watches for dynamically inserted ads
    • Catches ads added by JavaScript
    • 100ms debounce for performance

2. Smart Pattern Matching

Consolidated Pattern Categories:

Performance Optimizations:

3. Strict Mode

Enable aggressive blocking with additional patterns:

Warning: Strict mode may block legitimate content. Test on your sites first.

Optional feature to hide cookie consent banners:

Enable via bundle options in site editor.

5. Allowlist Support

Whitelist specific domains or paths:

Configuration Options

Strict Mode

Inline Ad Heuristics

Allowlist URL

Performance Characteristics

Benchmark (tested on ad-heavy news site):

Metric Before Optimization After Optimization Improvement
URL pattern matching 1.2ms (indexOf loops) 0.05ms (regex) 24x faster
DOM insertion overhead High (all nodes) Low (SCRIPT/IFRAME only) ~60% reduction
Repeated URL checks Uncached Cached 100x faster
Regex compilation Every check Once per page Instant

Memory Usage:

Current Coverage

~50 domains/patterns organized by category:

Known Limitations

  1. Static Filters
    • Patterns are hardcoded in bundle
    • No automatic updates
    • Misses newer ad networks
  2. Coverage
    • ~30-50% of modern ad networks
    • Community lists (EasyList) have 10,000+ rules
    • Trade-off: size vs coverage
  3. Site-Specific Issues
    • May break sites with aggressive anti-adblock
    • Some content behind paywalls may be hidden
    • Use allowlist to whitelist sites
  4. Chrome 47 Limitations
    • No :has() selector (can’t target parents)
    • No fetch() in some contexts (use XHR)
    • Limited CSS features

Future Improvements

See BUNDLE-REVIEW.md for detailed analysis:

  1. Build-Time Filter Integration (Priority: HIGH)
    • Pull filters from EasyList/Peter Lowe’s List
    • Bake into bundle during npm run build
    • Increase coverage to ~3,500 domains
    • Estimated size: +5KB (gzipped)
  2. Regex-Based Hosts File (Priority: MEDIUM)
    • Convert hosts lists to single regex
    • Faster matching than substring search
    • Standard format across ad blockers
  3. Per-Domain Filter Sets (Priority: LOW)
    • Load site-specific rules only when needed
    • E.g., YouTube ad patterns only on youtube.com
    • Reduces overhead on other sites

Testing

Test Sites (Ad-Heavy)

What to Check

  1. ✅ Ads are hidden/blocked
  2. ✅ Page layout not broken
  3. ✅ No console errors
  4. ✅ Navigation still works
  5. ✅ Legitimate content not blocked

Debug Mode

Enable in TizenPortal diagnostics (Blue button):

Credits

License

Same as TizenPortal (see root LICENSE file)