How jackyzy823/rajiko works
Project type and purpose
• This is a cross-browser (Chrome/Firefox) extension (Manifest V3) called “Rajiko.”
• Its goal is to bypass geolocation restrictions on Japanese radio streaming services (radiko.jp, NHK, recochoku.jp, etc.), support live recording, timeshift download, and mobile usability.
File structure
• Top level:
• manifest.jsonc.tmpl – MV3 manifest template
• background.js – background service worker
• package.py – build/install script
• README.md, LICENSE
• _locales – i18n message catalogs
• Directories:
• modules/ – core logic split by feature: auth.js, recording.js, timeshift.js, rules.js, static.js, util.js
• pages/ – UI HTML & JS: popup.html/js, options.html/js, offscreen.html/js
• ui/ – CSS and injection scripts for specific target sites
• response/ – canned HTML responses for area-free/auth bypass (for local testing or mocks)
• Permissions & APIs in README:
• activeTab, cookies, storage, downloads, scripting, offscreen
• webRequest / declarativeNetRequest / webRequestBlocking
• targets: *.radiko.jp, *.smartstream.ne.jp, *.nhk.jp|or.jp, *.tver.jp, *.recochoku.jp
README for additional insights
• Uses a two-step “auth1”/“auth2” handshake mimicking Android app behavior.
• Records HLS/AAC, strips ID3 tags, concatenates segments.
• Offscreen page for Blob URL creation in Chrome.
• Content scripts to inject UI modifications or bypass dialogs on target sites.
Components & interactions
1. Browser Extension Host
– Background Service Worker (background.js)
– Offscreen Document (pages/offscreen.html + offscreen.js)
– Popup UI (pages/popup.html + popup.js)
– Options UI (pages/options.html + options.js)
2. Core Logic Modules (modules/*.js)
– auth.js (auth1/auth2 handshake)
– recording.js (live capture pipeline)
– timeshift.js (HLS segment download pipeline)
– rules.js (URL-matching for injection & requests)
– static.js (serve local assets if needed)
– util.js (common helpers)
3. Content Scripts & UI Injectors (ui/*.js, ui/*.css)
4. Storage & State
– chrome.storage.local (settings, token, area config, recording metadata)
5. Browser APIs
– webRequest / declarativeNetRequest (modify headers, bypass geo)
– downloads.download (save blob to local)
– cookies API (force area cookie)
– offscreen (AudioBlob creation in Chrome)
6. External Services
– Radiko API endpoints (auth1/auth2, HLS m3u8, AAC segments)
– Smartstream / radiko-cf.com (media storage)
– NHK / recochoku / tver (bonus streams)
• Background → loads modules/auth → issues auth1 request → receives token/keys → modules/auth → auth2 request → obtains location-validated session
• Background → modules/recording or modules/timeshift → requests HLS manifest + TS/AAC segments → pipes data to Offscreen page (or directly to downloads API)
• Offscreen page → constructs Blob URL → triggers downloads.download
• Background / Content Scripts → apply rules.js → intercept or inject requests/responses → bypass geo-checks
• Background → chrome.storage to read/write user settings (area, credentials)
• Content Scripts → ui/*.js & .css → modify target pages (e.g., TVer, Recochoku)
c. Architectural patterns & principles:
• Modular separation of concerns: authentication, recording, UI, utilities
• Event-driven background service worker responds to messages & browser triggers
• Use of offscreen document as worker for heavy binary processing
• DeclarativeNetRequest/webRequestBlocking pattern for request rewriting
d. Key technologies:
• JavaScript ES modules (in modules/*)
• Chrome MV3 APIs: service worker, offscreen, downloads, storage, webRequest
• i18n with _locales
• HLS streaming (ID3 tag stripping, AAC_ADTS concatenation)