diff --git a/bin/mtag/res/yt-ipr.user.js b/bin/mtag/res/yt-ipr.user.js index 10435246..38462aae 100644 --- a/bin/mtag/res/yt-ipr.user.js +++ b/bin/mtag/res/yt-ipr.user.js @@ -16,22 +16,27 @@ function main() { return; fetch(server + '?_=' + Date.now(), { method: "PUT", body: txt }); - console.log('[yt-ipr] yeet %d bytes, %s', txt.length, desc); + console.log('[yt-pdh] yeet %d bytes, %s', txt.length, desc); sent[mf_url] = 1; } function collect() { setTimeout(collect, interval * 1000); try { - var pd = document.querySelector('ytd-watch-flexy').playerData, - mu = pd.streamingData.dashManifestUrl || pd.streamingData.hlsManifestUrl, - desc = pd.videoDetails.videoId + ', ' + pd.videoDetails.title; + var pd = document.querySelector('ytd-watch-flexy'); + if (!pd) + return console.log('[yt-pdh] no video found'); - if (mu.length) - send(JSON.stringify(pd), mu, desc); + pd = pd.playerData; + var mu = pd.streamingData.dashManifestUrl || pd.streamingData.hlsManifestUrl; + if (!mu || !mu.length) + return console.log('[yt-pdh] no manifest found'); + + var desc = pd.videoDetails.videoId + ', ' + pd.videoDetails.title; + send(JSON.stringify(pd), mu, desc); } catch (ex) { - console.log("[yt-ipr]", ex); + console.log("[yt-pdh]", ex); } } collect(); @@ -40,4 +45,4 @@ function main() { var scr = document.createElement('script'); scr.textContent = '(' + main.toString() + ')();'; (document.head || document.getElementsByTagName('head')[0]).appendChild(scr); -console.log('[yt-ipr] a'); +console.log('[yt-pdh] a');