From c24f0d5e35b2fd15bd4080b456de63e6ec1b9ddc Mon Sep 17 00:00:00 2001 From: Dark_Ville Date: Sun, 29 Dec 2024 18:32:10 +0100 Subject: [PATCH] chore(V Live): delete presence --- websites/V/V LIVE/metadata.json | 105 ------- websites/V/V LIVE/presence.ts | 474 -------------------------------- 2 files changed, 579 deletions(-) delete mode 100644 websites/V/V LIVE/metadata.json delete mode 100644 websites/V/V LIVE/presence.ts diff --git a/websites/V/V LIVE/metadata.json b/websites/V/V LIVE/metadata.json deleted file mode 100644 index e92cda112e7c..000000000000 --- a/websites/V/V LIVE/metadata.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "V LIVE", - "altnames": [ - "VLIVE" - ], - "description": { - "en": "V LIVE is a global entertainment platform that connects Korean stars and their fans.", - "nl": "V LIVE is een wereldwijd entertainmentplatform dat Koreaanse sterren en hun fans met elkaar verbindt.", - "ga_IE": "Is ardán siamsaíochta domhanda é V LIVE a nascann réaltaí na Cóiré agus a lucht leanúna." - }, - "url": "www.vlive.tv", - "version": "2.0.27", - "logo": "https://cdn.rcd.gg/PreMiD/websites/V/V%20LIVE/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/V/V%20LIVE/assets/thumbnail.png", - "color": "#54f7ff", - "category": "videos", - "tags": [ - "video", - "media", - "streaming", - "kpop" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "browse", - "title": "Show Browsing Status", - "icon": "fad fa-book-reader", - "value": true - }, - { - "id": "live", - "title": "Show Livestreams", - "icon": "fad fa-podcast", - "value": true - }, - { - "id": "streamDetail", - "if": { - "privacy": false - }, - "title": "Stream Details row1", - "icon": "fas fa-comment-alt-edit", - "value": "%title%", - "placeholder": "Use %title% or %streamer%" - }, - { - "id": "streamState", - "if": { - "privacy": false - }, - "title": "Stream Details row2", - "icon": "fas fa-comment-alt-edit", - "value": "%streamer%", - "placeholder": "Use %title% or %streamer%" - }, - { - "id": "video", - "title": "Show Videos", - "icon": "fas fa-video", - "value": true - }, - { - "id": "vidDetail", - "if": { - "privacy": false - }, - "title": "Video Details row1", - "icon": "fas fa-comment-alt-edit", - "value": "%title%", - "placeholder": "Use %title% or %uploader%" - }, - { - "id": "vidState", - "if": { - "privacy": false - }, - "title": "Video Details row2", - "icon": "fas fa-comment-alt-edit", - "value": "%uploader%", - "placeholder": "Use %title% or %uploader%" - }, - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - } - ] -} \ No newline at end of file diff --git a/websites/V/V LIVE/presence.ts b/websites/V/V LIVE/presence.ts deleted file mode 100644 index 0c3a30a414a0..000000000000 --- a/websites/V/V LIVE/presence.ts +++ /dev/null @@ -1,474 +0,0 @@ -const presence = new Presence({ - clientId: "614386371532161054", - injectOnComplete: true, -}); - -async function getStrings() { - return presence.getStrings( - { - play: "general.playing", - pause: "general.paused", - live: "general.live", - browse: "general.browsing", - watchingLive: "general.watchingLive", - watchingVid: "general.watchingVid", - waitingVid: "general.waitingVid", - waitingVidThe: "general.waitingVidThe", - waitingLive: "general.waitingLive", - waitingLiveThe: "general.waitingLiveThe", - readingPost: "general.readingPost", - readingAbout: "general.readingAbout", - searchFor: "general.searchFor", - searchSomething: "general.searchSomething", - browseThrough: "vlive.browseThrough", - newVid: "vlive.newVid", - charts: "vlive.charts", - upcoming: "vlive.upcoming", - channelList: "vlive.channelList", - events: "vlive.events", - store: "vlive.store", - recentUploads: "vlive.recentUploads", - ofChannel: "vlive.ofChannel", - channelHome: "vlive.channelHome", - channelSchedule: "vlive.channelSchedule", - channelMy: "vlive.channelMy", - channelStore: "vlive.channelStore", - channelBoard: "vlive.channelBoard", - product: "vlive.product", - profileEdit: "vlive.profileEdit", - viewTheir: "vlive.viewTheir", - profile: "vlive.profile", - watched: "vlive.watched", - purchases: "vlive.purchases", - coins: "vlive.coins", - devices: "vlive.devices", - followed: "vlive.followed", - policies: "vlive.policies", - }, - await presence.getSetting("lang").catch(() => "en") - ); -} - -let elapsed = Math.floor(Date.now() / 1000), - prevUrl = document.location.href, - strings: Awaited>, - oldLang: string = null; - -presence.on("UpdateData", async () => { - if (document.location.href !== prevUrl) { - prevUrl = document.location.href; - elapsed = Math.floor(Date.now() / 1000); - } - const [ - privacy, - showBrowsing, - showLive, - showVideo, - showTimestamps, - newLang, - vidDetail, - vidState, - streamDetail, - streamState, - ] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("browse"), - presence.getSetting("live"), - presence.getSetting("video"), - presence.getSetting("timestamp"), - presence.getSetting("lang"), - presence.getSetting("vidDetail"), - presence.getSetting("vidState"), - presence.getSetting("streamDetail"), - presence.getSetting("streamState"), - ]); - - let presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/V/V%20LIVE/assets/logo.png", - startTimestamp: elapsed, - }, - searchPageValue: string; - - if (!privacy) { - searchPageValue = - document.querySelector("#searchForm > input")?.value ?? - "ERROR: NOT FOUND!"; - } - - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } - - const path = location.pathname.replace(/\/?$/, "/"), - channelPageChannelName = document.querySelector( - "#root > div > div > div > nav > div > a > strong" - ) - ? document.querySelector( - "#root > div > div > div > nav > div > a > strong" - ).textContent - : "ERROR: NOT FOUND!", - statics: { - [name: string]: PresenceData; - } = { - "/home/new/": { - details: strings.browseThrough, - state: strings.newVid, - smallImageKey: Assets.Reading, - }, - "/home/chart/": { - details: strings.browseThrough, - state: strings.charts, - smallImageKey: Assets.Reading, - }, - "/home/my/": { - details: strings.recentUploads.includes("{0}") - ? strings.recentUploads.split("{0}")[0] - : strings.recentUploads, - state: strings.recentUploads.split("{0}")[1], - smallImageKey: Assets.Reading, - }, - "/my/": { - details: strings.viewTheir, - state: strings.profile, - smallImageKey: Assets.Reading, - }, - "/my/profile/": { - details: strings.profileEdit.includes("{0}") - ? strings.profileEdit.split("{0}")[0] - : strings.profileEdit, - state: strings.profileEdit.split("{0}")[1], - smallImageKey: Assets.Search, - }, - "/my/watched/": { - details: strings.viewTheir, - state: strings.watched, - smallImageKey: Assets.Reading, - }, - "/my/purchased/": { - details: strings.viewTheir, - state: strings.purchases, - smallImageKey: Assets.Reading, - }, - "/my/coin/": { - details: strings.viewTheir, - state: strings.coins, - smallImageKey: Assets.Reading, - }, - "/my/devices/": { - details: strings.viewTheir, - state: strings.devices, - smallImageKey: Assets.Reading, - }, - "/my/channels/": { - details: strings.viewTheir, - state: strings.followed, - smallImageKey: Assets.Reading, - }, - "/upcoming/": { - details: strings.browseThrough, - state: strings.upcoming, - smallImageKey: Assets.Reading, - }, - "/channels/": { - details: strings.browseThrough, - state: strings.channelList, - smallImageKey: Assets.Reading, - }, - "/channel/(\\w*\\d*)/": { - details: strings.channelHome, - state: strings.ofChannel.replace("{0}", channelPageChannelName), - smallImageKey: Assets.Reading, - }, - "/channel/(\\w*\\d*)/schedule/": { - details: strings.channelSchedule, - state: strings.ofChannel.replace("{0}", channelPageChannelName), - smallImageKey: Assets.Reading, - }, - "/channel/(\\w*\\d*)/my/": { - details: strings.channelMy, - state: strings.ofChannel.replace("{0}", channelPageChannelName), - smallImageKey: Assets.Reading, - }, - "/channel/(\\w*\\d*)/store/": { - details: strings.channelStore, - state: strings.ofChannel.replace("{0}", channelPageChannelName), - smallImageKey: Assets.Reading, - }, - "/channel/(\\w*\\d*)/board/": { - details: strings.channelBoard.replace( - "{0}", - document.querySelector("#root > div > div > div > div > div > h2") - ?.textContent ?? "ERROR: NOT FOUND!" - ), - state: strings.ofChannel.replace("{0}", channelPageChannelName), - smallImageKey: Assets.Reading, - }, - "/events/": { - details: strings.browseThrough, - state: strings.events, - smallImageKey: Assets.Reading, - }, - "/vstore/": { - details: strings.browseThrough, - state: strings.store, - smallImageKey: Assets.Reading, - }, - "/product/(\\w*\\d*)/": { - details: strings.product.replace( - "{0}", - document.querySelector("a.name")?.textContent ?? "ERROR: NOT FOUND!" - ), - state: - document.querySelector("h3.tit")?.textContent ?? "ERROR: NOT FOUND!", - smallImageKey: Assets.Reading, - }, - "/search/": { - details: privacy ? strings.searchSomething : strings.searchFor, - state: searchPageValue, - smallImageKey: Assets.Search, - }, - "/policies/": { - details: strings.policies, - smallImageKey: Assets.Reading, - }, - "/about/": { - details: `${strings.readingAbout} V LIVE`, - smallImageKey: Assets.Reading, - }, - }; - - if (showBrowsing) { - for (const [k, v] of Object.entries(statics)) - if (path.match(k)) presenceData = { ...presenceData, ...v }; - - if (privacy) { - presenceData.details = strings.browse; - presenceData.smallImageKey = Assets.Reading; - delete presenceData.state; - } - } - - //* Video page - if (path.match("/video/(\\d*)/")) { - const video = document.querySelector("video"), - badge = document.querySelector( - "#root > div > div > div > div > div > div > div > div > div > span > em" - ), - title = document.querySelector( - "#root > div > div > div > div > div > div > div > div > div > span > strong" - ) - ? document.querySelector( - "#root > div > div > div > div > div > div > div > div > div > span > strong" - ).textContent - : "ERROR: NOT FOUND!"; - - if (video) { - if (badge && badge.className.includes("-liveon--")) { - //* Is a livestream - if (showLive) { - if (document.querySelector(".timeBox")) { - presenceData.startTimestamp = Math.floor( - Date.now() / 1000 - - presence.timestampFromFormat( - document.querySelector(".timeBox").textContent - ) - ); - } - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Live; - presenceData.smallImageText = video.paused - ? strings.pause - : strings.live; - presenceData.details = streamDetail - .replace("%title%", title) - .replace("%streamer%", channelPageChannelName); - presenceData.state = streamState - .replace("%title%", title) - .replace("%streamer%", channelPageChannelName); - - if (video.paused) delete presenceData.startTimestamp; - } - - //* Privacy mode enabled. - if (privacy && showLive) { - presenceData.details = strings.watchingLive; - delete presenceData.state; - } else if (showBrowsing && !showLive) { - presenceData.details = strings.browse; - presenceData.smallImageKey = Assets.Reading; - delete presenceData.state; - } - } else { - //* Is a a normal video - if (showVideo) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Play; - presenceData.smallImageText = video.paused - ? strings.pause - : strings.play; - presenceData.details = vidDetail - .replace("%title%", title) - .replace("%uploader%", channelPageChannelName); - presenceData.state = vidState - .replace("%title%", title) - .replace("%uploader%", channelPageChannelName); - - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } - - //* Privacy mode enabled. - if (privacy && showVideo) { - presenceData.details = strings.watchingVid; - delete presenceData.state; - } else if (showBrowsing && !showVideo) { - presenceData.details = strings.browse; - presenceData.smallImageKey = Assets.Reading; - delete presenceData.state; - } - } - } else if ( - document.querySelector( - "#root > div > div > div > div > div > div > div > div > div> div > div > div > strong" - ) - ) { - //* Video not out yet... - if (badge && badge.className.includes("-live--")) { - //* Will be a livestream - if (showLive) { - presenceData.details = streamDetail - .replace("%title%", title) - .replace("%streamer%", channelPageChannelName); - presenceData.state = streamState - .replace("%title%", title) - .replace("%streamer%", channelPageChannelName); - presenceData.smallImageKey = Assets.PremiereLive; - presenceData.smallImageText = strings.waitingLiveThe; - } - - //* Privacy mode enabled. - if (privacy && showLive) { - presenceData.details = strings.waitingLive; - delete presenceData.state; - delete presenceData.smallImageText; - } else if (showBrowsing && !showLive) { - presenceData.details = strings.browse; - presenceData.smallImageKey = Assets.Reading; - delete presenceData.state; - delete presenceData.smallImageText; - } - } else { - //* Will be a normal video - if (showVideo) { - presenceData.details = vidDetail - .replace("%title%", title) - .replace("%uploader%", channelPageChannelName); - presenceData.state = vidState - .replace("%title%", title) - .replace("%uploader%", channelPageChannelName); - presenceData.smallImageKey = Assets.Premiere; - presenceData.smallImageText = strings.waitingVidThe; - } - - //* Privacy mode enabled. - if (privacy && showVideo) { - presenceData.details = strings.waitingVid; - delete presenceData.state; - delete presenceData.smallImageText; - } else if (showBrowsing && !showVideo) { - presenceData.details = strings.browse; - presenceData.smallImageKey = Assets.Reading; - delete presenceData.state; - delete presenceData.smallImageText; - } - } - } - } - - //* Post page - if (path.match("/post/(\\d*-\\d*)/")) { - const video = document.querySelector("video"), - videoTitle = document.querySelector( - "#root > div > div > div > div > div > div > div > div > div > span > strong" - ), - videoPoster = document.querySelector( - "#root > div > div > div > div > div > div > div > div > div > div > div > a > span" - ), - postTitle = document.querySelector( - "#root > div > div > div > div > div > div > div > strong" - ), - postPoster = document.querySelector( - "#root > div > div > div > div > div > div > div > div > div > a > span" - ); - - if (video && videoTitle && videoPoster) { - //* Has video - if (showVideo) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? strings.pause - : strings.play; - presenceData.details = vidDetail - .replace("%title%", videoTitle.textContent) - .replace("%uploader%", videoPoster.textContent); - presenceData.state = vidState - .replace("%title%", videoTitle.textContent) - .replace("%uploader%", videoPoster.textContent); - - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } - - //* Privacy mode enabled. - if (privacy && showVideo) { - presenceData.details = strings.watchingVid; - delete presenceData.state; - } else if (showBrowsing && !showVideo) { - presenceData.details = strings.browse; - delete presenceData.state; - } - } else if (postTitle && postPoster) { - //* Normal text post - presenceData.details = `${strings.readingPost} (${postPoster.textContent})`; - presenceData.state = postTitle.textContent; - presenceData.smallImageKey = Assets.Reading; - } - } - - if (presenceData.details) { - if (!showTimestamps) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - - presence.setActivity(presenceData); - - if ( - (presenceData.details as string).includes("ERROR: NOT FOUND!") || - (presenceData.state && - (presenceData.state as string).includes("ERROR: NOT FOUND!")) - ) { - presence.error( - `Unable to find an element...\nPlease contact Bas950#0950 in Discord (https://discord.premid.app/).\nPath: ${path}` - ); - } - } else { - presence.setActivity(); - - presence.info( - `Looks like your current page is unsupported!\nPlease contact Bas950#0950 in Discord (https://discord.premid.app/).\nPath: ${path}` - ); - } -});