You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1 lines
2.8 KiB

(()=>{"use strict";setTimeout((()=>{const e="webvtt-lssdh-ios8",t=new RegExp("manifest|licensedManifest"),n=new Map;function s(){if("undefined"!=typeof netflix)return netflix?.appContext?.state?.playerApp?.getAPI?.()}function a(){return s()?.videoPlayer}function i(){const e=a();if(e){const t=e.getAllPlayerSessionIds?.()||[];if(0===t.length)return void console.error("No Netflix player session IDs");const n=t[t.length-1];return e.getVideoPlayerBySessionId?.(n)}console.error("Missing netflix global")}function r(t){if(t.isForcedNarrative||t.isNoneTrack||!t.cdnlist?.length||!t.ttDownloadables)return;const n=t.ttDownloadables[e];return n?.downloadUrls?n.downloadUrls[t.cdnlist.find((e=>n.downloadUrls[e.id]))?.id]:void 0}function o(t){if(t.isForcedNarrative||t.isNoneTrack||!t.ttDownloadables)return;const n=t.ttDownloadables[e];return n?.urls&&0!==n.urls.length?n.urls[0].url:void 0}async function d(e,t){if(t<=0)return`${e}`;const[n,a]=function(e){const t=s()?.getVideoMetadataByVideoId?.(e)?.getCurrentVideo?.(),n=t?.getTitle?.();if("string"!=typeof n)return[`${e}`,!0];let a=n;if(!0===t?.isEpisodic?.()){const e=`${t?.getSeason()?._season?.seq}`.padStart(2,"0"),n=`${t?.getEpisodeNumber?.()}`.padStart(2,"0"),s=t?.getEpisodeTitle?.();a+=` S${e}E${n} ${s}`}return[a,!1]}(e);return a?(await new Promise((e=>setTimeout(e,1e3))),await d(e,--t)):n}document.addEventListener("asbplayer-netflix-seek",(e=>{i()?.seek(e.detail)})),document.addEventListener("asbplayer-netflix-play",(()=>{i()?.play()})),document.addEventListener("asbplayer-netflix-pause",(()=>{i()?.pause()})),document.addEventListener("asbplayer-get-synced-data",(async()=>{const e={error:"",basename:"",subtitles:[]},t=i(),s=t?.getMovieId();if(!t||!s)return e.error="Netflix Player or Title Id not found...",document.dispatchEvent(new CustomEvent("asbplayer-synced-data",{detail:e}));e.basename=await d(s,5);const a=n.get(s)||new Map;e.subtitles=t.getTimedTextTrackList().filter((e=>a.has(e.trackId))).map((e=>({label:`${e.bcp47} - ${e.displayName}${"CLOSEDCAPTIONS"===e.rawTrackType?" [CC]":""}`,language:e.bcp47.toLowerCase(),url:a.get(e.trackId),extension:"nfvtt"}))),document.dispatchEvent(new CustomEvent("asbplayer-synced-data",{detail:e}))}),!1);const l=JSON.stringify;JSON.stringify=function(n){if("string"==typeof n?.url&&-1<n.url.search(t))for(let t of Object.values(n))t?.profiles?.unshift(e);return l.apply(this,arguments)};const c=JSON.parse;JSON.parse=function(){const e=c.apply(this,arguments);return e?.result?.movieId&&function(e){const t=e.timedtexttracks||[];for(const s of t){const t=r(s)??o(s);t&&(n.has(e.movieId)||n.set(e.movieId,new Map),n.get(e.movieId).set(s.new_track_id,t))}}(e.result),e},document.addEventListener("asbplayer-query-netflix",(()=>{document.dispatchEvent(new CustomEvent("asbplayer-netflix-enabled",{detail:void 0!==a()}))}))}),0)})();