Back to all writing
Project Log

Bilibili-oversea: A Local Adaptive CDN Tool

GitHub

A local CDN selection tool for browsers and iPhone/iPad that prioritizes playback, verifies routes after safe buffering, and keeps an original-CDN fallback.

Install / v2.2.0

Choose your device.

This page only hands the public configuration to your device. Measurement, selection, and switching all happen locally.

01 / Browser

Chrome / Edge

A standalone MV3 extension. Unzip it and load it from the browser extension manager; no proxy or certificate is required.

02 / iPhone · iPad

Network-tool modules

Choose one network tool you already use. This project does not provide proxy nodes or subscriptions.

Read the complete iOS installation and certificate guide below
03 / Automation

Connect automatically when Bilibili opens

The signed shortcut only invokes the native iOS “Connect VPN” action. After installation, create one personal automation in the Shortcuts app.

Install shortcut
04 / Local controls

Control and recovery

These addresses are intercepted only by the installed local script. With the network tool inactive, they do not connect to an external service.

Guide / Chrome · Edge

Complete browser-extension setup and usage guide.

Bilibili-oversea 2.2 is a Manifest V3 extension. Measurement, node selection, and rule switching happen locally. It provides no proxy, sends no telemetry, and does not bypass region, copyright, login, or membership restrictions.

01

Download and fully unzip

  1. Use the button above to download bilibili-oversea-browser-v2.2.0.zip.
  2. Extract the ZIP into a stable folder that will not be cleaned or moved.
  3. Open the extracted directory and confirm that manifest.json, src, and assets are directly inside it.
Do not load the ZIPThe browser needs the extracted folder. Select the exact directory that contains manifest.json.
02

Load it in Chrome or Edge

Chrome

  1. Open chrome://extensions.
  2. Enable Developer mode in the top-right corner.
  3. Select “Load unpacked” and choose the folder containing manifest.json.

Microsoft Edge

  1. Open edge://extensions.
  2. Enable Developer mode in the sidebar.
  3. Select “Load unpacked” and choose the folder containing manifest.json.
InstalledThe extension list will show Bilibili-oversea 2.2.0 with a cyan icon. Pin it from the extensions menu for easier access.
03

First run and automatic measurement

  1. After installation, refresh any open Bilibili video, anime, or course page, then start playback.
  2. The extension watches the player API first. If no media request is captured within 10 seconds, it falls back to scanning video resources on the page.
  3. If this network has a valid result from the last 3 hours, the cached winner is applied immediately.
  4. After playback has buffered safely for about 12 seconds, the extension performs a light comparison between the current node and the best backup without interrupting playback.
…Full benchmark running
·Light comparison running
AAutomatic mode
MFixed-node mode
—Original CDN
!Measurement or rule-install failure
04

Extension panel and switching modes

Select the toolbar icon to inspect the current target, recent media request, benchmark results, and dynamic-rule status.

Automatic mode

Clears a manually fixed node and remeasures the current video.

Retest

Ignores the current cache and runs a fresh full comparison for the playing video.

Use original CDN

Removes dynamic redirect rules for the current tab and restores the platform URL.

Fix a node

Locks only a verified node. Playback rewinds slightly after switching so the player can request the stream again.

Disable a candidate

Excludes a repeatedly failing or unsuitable node from later measurements.

Background maintenance

The first light comparison waits for safe buffering, then maintenance runs about every 15 minutes rather than continuously consuming bandwidth.

05

Confirm that the extension is working

  1. Open the panel and confirm that the current tab, recent media URL, and rule state are visible.
  2. A valid measurement normally shows a bilivideo host, an HTTP 206 partial response, and an installed rule beside the winner.
  3. Seek to an uncached point or open another video, then confirm that the recent-media and target fields update.
Original may remainIf no candidate is faster, the extension keeps the original node. That is not a failure, and improvement is not guaranteed for every video or network.
06

Update and uninstall

Update

  1. Download and extract the new version, replacing the stable extension folder.
  2. Return to the extensions page and select Reload on the extension card.
  3. Refresh any Bilibili pages that were already open.

Uninstall

  1. Find Bilibili-oversea on the extensions page.
  2. Select Remove, then refresh Bilibili tabs.
  3. Delete the extracted folder after confirming it is no longer in use.
07

Common troubleshooting

Stuck on “waiting for video”

Refresh and start playback. Disable extensions that replace the player or block media requests, then check site access.

All candidates failed

Switch to the original CDN and confirm the video itself plays, then retest. Corporate, campus, or public networks may block some candidates.

Playback stops after switching

Wait a few seconds or seek slightly backward. If playback does not recover, choose Original CDN, refresh, and retest.

Need implementation details

This page contains the complete operating guide. Source code and the Markdown documentation remain available for review in the GitHub repository.

08

Permissions, traffic, and privacy boundaries

  • The extension does not request proxy, cookie, browsing-history, webRequest, or all-sites access.
  • Its access is limited to relevant Bilibili pages and bilivideo media hosts.
  • The full recent-media URL stays only in extension background memory and is not uploaded to telemetry.
  • A full benchmark theoretically transfers about 4 MB. Routine light comparison checks only 2 nodes at roughly 256 KB each.
  • The extension source is public in the project repository, including permissions, measurement logic, and dynamic rules.
Security boundaryDeveloper-mode installation shows a standard warning. Download only from the project release location and verify the source before updating.
Guide / iOS · iPadOS

Complete setup and automatic-start guide.

Setup is a one-time process. Afterwards, opening the official Bilibili app can connect the VPN that carries Bili CDN Auto; once playback begins, the script measures candidate CDNs and uses the more suitable route for the current network.

00

Before you start

  • iOS/iPadOS 16.4 or later is recommended for the native “Connect VPN” Shortcuts action.
  • Use one of Surge, Shadowrocket, Loon, or Stash. Do not connect multiple VPN tools at once.
  • Your network tool must already have a working main configuration. Bili CDN Auto is a module/plugin; it does not provide proxy nodes or subscriptions.
ScopeIt only optimizes video-CDN routing. It cannot bypass region, copyright, login, or membership restrictions.
01

Import Bili CDN Auto

Use the buttons above to import only the configuration for the network tool you actually use.

Shadowrocket

  1. Select Shadowrocket above and allow the browser to open the app.
  2. Add Bili CDN Auto on the import screen and keep the defaults.
  3. Confirm that it exists and is enabled under configuration/modules.
  4. Return home and select your usual profile or node.

Surge

  1. Select Surge above and allow the browser to open it.
  2. Confirm installation on the module screen.
  3. Go to Surge → Current Profile → Modules and confirm it is enabled.
  4. Keep defaults initially; candidate nodes and cache duration can be adjusted later.

Loon

  1. Select Loon above, allow the app to open, and confirm plugin import.
  2. Go to Loon → Configuration → Plugins and confirm it is enabled.
  3. Keep the candidate CDN and cache settings at their defaults.

Stash

  1. Select Stash above and confirm installation of the Bili CDN Auto Override.
  2. Go to Stash → Override and confirm it is enabled.
  3. Confirm that your existing main profile remains selected.
Quantumult X / ExperimentalDownload the .snippet above, merge its [rewrite_local] and [mitm] sections into your own configuration, then refresh resources. Quantumult X has no equivalent one-tap module flow; use it only if you understand its format.
02

Generate, install, and trust your own certificate

Video requests use HTTPS. Your network tool can run the CDN-request script only after the device trusts the CA generated locally by that tool.

  • Shadowrocket:Settings → Certificate; generate a new CA, then install it.
  • Surge:Home/More → MitM; generate a new CA and install the system profile.
  • Loon:Configuration/Settings → MitM → Certificate; generate and install it.
  • Stash:Home → MitM → CA Certificate → Stash Generated CA → Install.
  1. Open Settings → General → VPN & Device Management (or “Profile Downloaded”).
  2. Open the downloaded profile and tap Install.
  3. Go to Settings → General → About → Certificate Trust Settings.
  4. Enable full trust for the certificate you just generated.
  5. Return to the network tool and confirm MitM/HTTPS decryption is enabled.
SecurityUse only the certificate generated by the network tool on your own device. Never download, share, or install another person's CA, private key, or .p12. The module limits decrypted hosts to relevant Bilibili video-CDN domains.
03

First connection and basic verification

  1. Start the connection in your network tool and allow iOS to add its VPN profile.
  2. Return here and select “View status” above.
  3. A JSON response containing "ok": true means the local control script is loaded.
  4. Open Bilibili and play a video that is not fully cached for at least 15–25 seconds.
  5. Check status again. Normally, selectedHost is non-empty and scores contains measurements.
Playback firstThe first media request never waits for a benchmark: it immediately uses a cached winner when available, otherwise the original CDN. Safe measurement can begin only on a later request after at least 15 seconds; without another request, playback stays on the original route.

If “View status” fails immediately, the network tool is usually disconnected, the module is disabled, or the main profile did not load it.

04

Install the “Connect VPN” shortcut

  1. Select “Install shortcut” above.
  2. Inspect it in Shortcuts: it contains only one system action, “Connect VPN.”
  3. Tap “Add Shortcut.”
  4. If the device has multiple VPNs, edit the VPN field and choose the client carrying Bili CDN Auto.
  5. Run it once, allow the connection, and confirm the VPN indicator appears without switching to another app.

The file is signed with the macOS Shortcuts “Anyone” import mode and contains no accounts, API keys, proxy nodes, or remotely executed code.

05

Create a personal “When Bilibili opens” automation

Apple does not allow a downloaded file to silently create a personal automation, so confirm these steps once on-device:

  1. Open Shortcuts and go to Automation.
  2. Tap + at the top right, or “New Automation” on first use.
  3. Choose “App.”
  4. Tap “Choose,” select Bilibili, then confirm.
  5. Select “Is Opened,” not “Is Closed.”
  6. Choose “Run Immediately”; the run notification can be disabled if offered.
  7. Continue and choose “New Blank Automation.”
  8. Add the “Run Shortcut” action.
  9. Tap the blue Shortcut field and choose BiliCDNAuto-ConnectVPN.
  10. Tap Done.

To test, close Bilibili and the network tool, then open the official Bilibili app. The VPN should connect while the app remains visible; CDN selection runs in the background after playback starts.

06

Daily use and default policy

  • Normally, just open Bilibili; there is no need to revisit the network tool or this page.
  • After changing Wi-Fi or cellular networks, the old choice expires; the first request uses the original CDN and selection resumes after the safety delay.
  • If playback becomes clearly slower, select “Retest,” then seek to uncached content or reopen the video.
  • “Original CDN” restores the platform default, “Automatic mode” re-enables selection, and selectedHost in status shows the current node.
Do not retest on every launchSuccessful results are cached for 3 hours and failures for 10 minutes. After 15 seconds on a new video and every 15 minutes thereafter, only the current node and best fallback are compared at 128 KiB each. A full benchmark also uses parallel 128 KiB requests per node for up to about 4 seconds, and runs only when there is no cache, playback slows, a node fails, the network changes, or candidates are exhausted.

iOS network tools cannot read the player's buffer, so they cannot sample it every two seconds like the browser extension. The 15-second safety delay is a conservative request-layer approximation.

07

Troubleshooting

VPN does not connect when the app opens

  • Run the shortcut manually and confirm it connects the correct VPN.
  • Confirm the automation is enabled, targets Bilibili, and is set to Run Immediately.
  • With multiple VPNs, select the correct one again. On older iOS, use on-demand connection or a URL Scheme below.

selectedHost stays empty

  • Confirm the module is enabled and the certificate is installed and fully trusted.
  • Play a new video or seek to uncached content, then run “Retest” once.

Certificate error or no connectivity

Stop the network tool immediately and retry with the module disabled. Check for someone else's certificate, expiry, or conflicting MitM/rewrite rules; remove and regenerate the profile if needed.

No improvement after automatic measurement

Candidate CDNs may perform similarly on your carrier, or the bottleneck may be elsewhere. The original node is retained when no candidate is better, and improvement is not guaranteed for every video route.

08

URL Scheme fallback

If the system “Connect VPN” action cannot identify your client, use an “Open URL” action in the personal automation:

Surgesurge:///start?autoclose=true
Shadowrocketshadowrocket://connect?autoclose=true
Loonloon://on
Stashstash://start

For Surge and Shadowrocket, autoclose=true returns to the previous app after connecting. Loon and Stash behavior varies by version, so prefer the system action or on-demand connection.

09

Uninstall and restore

  1. Delete the “When Bilibili opens” automation in Shortcuts → Automation.
  2. Delete the BiliCDNAuto-ConnectVPN shortcut.
  3. Disable or delete the Bili CDN Auto module/plugin/Override in the network tool.
  4. If you no longer use HTTPS decryption, remove its certificate profile under Settings → General → VPN & Device Management.
  5. Stop the VPN; Bilibili returns to the platform's original CDN behavior.

What it solves

Bilibili-oversea addresses cases where the same video performs very differently across bilivideo.com CDN hosts. It compares viable routes locally and sends later media requests to a better host for the current network. The browser edition runs as a Chrome / Edge extension; the iPhone and iPad edition uses the local scripting capabilities of Surge, Loon, Shadowrocket, Stash, or Quantumult X.

Playback-first behavior

A new video is never held back for a benchmark. A recent cached winner is applied immediately; otherwise playback starts on the original CDN. The browser extension verifies routes after the player has safe buffer, while the mobile edition waits for a later media request before running a lightweight comparison. Failed candidates rotate to a verified fallback, with the original CDN always available.

Security and privacy boundaries

  • Measurements, selections, and status remain on the device; there is no telemetry or remote control service.
  • The project does not provide proxy nodes, subscriptions, or shared certificates.
  • On iOS, users must generate and trust their own MITM certificate inside their network tool. Never install a CA, private key, or .p12 file supplied by someone else.
  • The tool can improve CDN route selection, but it cannot guarantee that every video becomes faster and does not bypass copyright, regional, or platform-signature restrictions.

Maintenance and recovery

The browser extension can return to the original CDN at any time or be removed completely. On iOS, disable the module in the network tool and remove the personal automation, shortcut, and any certificate that is no longer needed. Bilibili then returns to its original network behavior. Source, configuration templates, and release history remain available in the GitHub repository.