Files
2026-04-25 21:24:34 +00:00

2 lines
2.0 KiB
JavaScript

"use strict";var l=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var n in t)l(e,n,{get:t[n],enumerable:!0})},m=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of u(t))!c.call(e,i)&&i!==n&&l(e,i,{get:()=>t[i],enumerable:!(r=s(t,i))||r.enumerable});return e};var f=e=>m(l({},"__esModule",{value:!0}),e);var A={};d(A,{default:()=>w});module.exports=f(A);var o=Object.freeze({PLAYING:0,LISTENING:2,WATCHING:3});function h(){return document.querySelector("video")}function p(){return(document.querySelector("[data-uia='video-title'] h4")??document.querySelector(".video-title h4")??document.querySelector("[data-uia='player-title']"))?.textContent?.trim()??null}function y(){let e=document.querySelector("[data-uia='video-title']")??document.querySelector(".video-title");if(!e)return null;let t=Array.from(e.querySelectorAll("span")).map(n=>n.textContent?.trim()).filter(n=>!!n&&n.length>0);return t.length>0?t.join(" \xB7 "):null}function g(){return location.pathname.startsWith("/watch/")}function T(){return location.pathname.startsWith("/browse/genre")?"Browsing genres":location.pathname.startsWith("/latest")?"Browsing new releases":location.pathname.startsWith("/my-list")?"Browsing my list":location.pathname.startsWith("/search")?"Searching":location.pathname.startsWith("/title/")?"Viewing title":"Browsing"}var w={match:["https://www.netflix.com/*"],tickInterval:1500,tick(e){if(!g()){e.setActivity({type:o.WATCHING,name:"Netflix",details:T()});return}let t=h(),n=p();if(!t||!n){e.setActivity({type:o.WATCHING,name:"Netflix",details:"Loading\u2026"});return}let r=y(),i=t.paused,a=Number.isFinite(t.duration)&&t.duration>0?Math.floor((t.duration-t.currentTime)*1e3):null;e.setActivity({type:o.WATCHING,name:"Netflix",details:n,state:r?`${i?"Paused":"Watching"} \xB7 ${r}`:i?"Paused":"Watching",url:location.href,startedAt:i?null:Date.now()-Math.floor(t.currentTime*1e3),endsAt:i||a===null?null:Date.now()+a})}};