SPA遷移の修正
This commit is contained in:
parent
35bcdfba7d
commit
65e2f28f8e
|
|
@ -16,6 +16,7 @@
|
||||||
w.__yt_playlist_ext_injected = true;
|
w.__yt_playlist_ext_injected = true;
|
||||||
|
|
||||||
let extractingUrl: string | null = null;
|
let extractingUrl: string | null = null;
|
||||||
|
let isInitialLoad = true;
|
||||||
let collabCache: Map<string, string> = new Map();
|
let collabCache: Map<string, string> = new Map();
|
||||||
let collabCachePlaylistId: string | null = null;
|
let collabCachePlaylistId: string | null = null;
|
||||||
|
|
||||||
|
|
@ -64,12 +65,13 @@
|
||||||
const { cfg, apiKey, baseContext } = getConfig();
|
const { cfg, apiKey, baseContext } = getConfig();
|
||||||
const authHeaders = buildAuthHeaders(cfg, baseContext);
|
const authHeaders = buildAuthHeaders(cfg, baseContext);
|
||||||
|
|
||||||
// Try ytInitialData first (works on initial page load)
|
// Try ytInitialData only on initial page load.
|
||||||
let initialData = w.ytInitialData;
|
// On SPA navigation ytInitialData is stale (still holds the previous page's data),
|
||||||
|
// so we must always fetch fresh data via the browse API.
|
||||||
|
let initialData = isInitialLoad ? w.ytInitialData : null;
|
||||||
let videoList = initialData ? findVideoListContents(initialData) : null;
|
let videoList = initialData ? findVideoListContents(initialData) : null;
|
||||||
|
isInitialLoad = false;
|
||||||
|
|
||||||
// If ytInitialData doesn't have the video list (SPA navigation),
|
|
||||||
// fetch the playlist data ourselves via the browse API
|
|
||||||
if (!videoList) {
|
if (!videoList) {
|
||||||
const playlistId = getPlaylistId();
|
const playlistId = getPlaylistId();
|
||||||
if (!playlistId) {
|
if (!playlistId) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user