-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(UFC Fight Pass): add activity #10673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "$schema": "https://schemas.premid.app/metadata/1.16", | ||
| "apiVersion": 1, | ||
| "author": { | ||
| "id": "922677780074881045", | ||
| "name": "_y3n" | ||
| }, | ||
| "service": "UFC Fight Pass", | ||
Check failureCode scanning / PMD Makes sure the service folder is correct Error
Expected service folder to be UFC Fight Pass, but got dist
|
||
|
|
||
| "description": { | ||
| "en": "Watch UFC fights, live events, replays and highlights." | ||
| }, | ||
| "url": [ | ||
| "ufcfightpass.com", | ||
| "www.ufcfightpass.com" | ||
| ], | ||
| "regExp": "^https?://([a-z0-9-]+\\.)*ufcfightpass\\.com/?", | ||
| "version": "1.0.0", | ||
| "logo": "https://i.imgur.com/hVg7eP2.jpg", | ||
Check failureCode scanning / PMD Makes sure all images (logo and URLs) are exactly 512x512 pixels Error
Image URL dimensions must be exactly 512x512 pixels, got 558x445 for URL: https://i.imgur.com/hVg7eP2.jpg
|
||
|
|
||
| "thumbnail": "https://i.imgur.com/hVg7eP2.jpg", | ||
| "color": "#e10600", | ||
| "category": "videos", | ||
| "tags": [ | ||
| "ufc", | ||
| "mma", | ||
| "fight", | ||
| "sports", | ||
| "streaming", | ||
| "fightpass" | ||
| ] | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "$schema": "https://schemas.premid.app/metadata/1.16", | ||
| "apiVersion": 1, | ||
| "author": { | ||
| "id": "922677780074881045", | ||
| "name": "_y3n" | ||
| }, | ||
| "service": "UFC Fight Pass", | ||
| "description": { | ||
| "en": "Watch UFC fights, live events, replays and highlights." | ||
| }, | ||
| "url": [ | ||
| "ufcfightpass.com", | ||
| "www.ufcfightpass.com" | ||
| ], | ||
| "regExp": "^https?://([a-z0-9-]+\\.)*ufcfightpass\\.com/?", | ||
| "version": "1.0.0", | ||
| "logo": "https://i.imgur.com/hVg7eP2.jpg", | ||
Check failureCode scanning / PMD Makes sure all images (logo and URLs) are exactly 512x512 pixels Error
Image URL dimensions must be exactly 512x512 pixels, got 558x445 for URL: https://i.imgur.com/hVg7eP2.jpg
|
||
|
|
||
| "thumbnail": "https://i.imgur.com/hVg7eP2.jpg", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Image should be a landscape promotional image or screenshot. This image is too similar to logo |
||
| "color": "#e10600", | ||
| "category": "videos", | ||
| "tags": [ | ||
| "ufc", | ||
| "mma", | ||
| "fight", | ||
| "sports", | ||
| "streaming", | ||
| "fightpass" | ||
| ] | ||
| } | ||
Check failureCode scanning / ESLint Require or disallow newline at the end of files Error
Newline required at end of file but not found.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { Assets } from "premid" | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
|
|
||
| const presence = new Presence({ | ||
| clientId: "1492178685946499122", | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
| }) | ||
|
|
||
| const IMAGE_KEY = "fightpassufc" | ||
Check failureCode scanning / ESLint Disallow unused variables Error
'IMAGE_KEY' is assigned a value but never used. Allowed unused vars must match /^_/u.
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable appears to be unused |
||
| const START_KEY = "ufc_start_time" | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
| const VIDEO_KEY = "ufc_video_id" | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
|
|
||
| function getMode(video: HTMLVideoElement, title: string) { | ||
| if (video.duration === Infinity || title.includes("live")) return "LIVE" | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
Check failureCode scanning / ESLint Newline after if Error
Expect newline after if
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
| if (title.includes("highlight")) return "HIGHLIGHTS" | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
Check failureCode scanning / ESLint Newline after if Error
Expect newline after if
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
| return "REPLAY" | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
| } | ||
|
|
||
| presence.on("UpdateData", async () => { | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
| const now = Math.floor(Date.now() / 1000) | ||
| const video = document.querySelector("video") as HTMLVideoElement | null | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use generics for querySelector |
||
| const title = document.title.trim() | ||
|
|
||
| const presenceData: PresenceData = { | ||
| largeImageKey: "https://i.imgur.com/hVg7eP2.jpg", | ||
Check failureCode scanning / PMD Makes sure all images (logo and URLs) are exactly 512x512 pixels Error
Image URL dimensions must be exactly 512x512 pixels, got 558x445 for URL: https://i.imgur.com/hVg7eP2.jpg
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
|
|
||
| smallImageKey: Assets.Play, | ||
| } | ||
|
|
||
| // 🏠 HOME | ||
| if (!video) { | ||
| sessionStorage.removeItem(START_KEY) | ||
| sessionStorage.removeItem(VIDEO_KEY) | ||
|
|
||
| presenceData.details = "Homepage" | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
| presenceData.state = "Browsing fights" | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
|
||
|
|
||
| presence.setActivity(presenceData) | ||
| return | ||
| } | ||
|
|
||
| const videoId = video.currentSrc || location.href | ||
| const savedVideoId = sessionStorage.getItem(VIDEO_KEY) | ||
|
|
||
| let startTimestamp = Number(sessionStorage.getItem(START_KEY)) | ||
|
|
||
| if ( | ||
| savedVideoId !== videoId || | ||
Check failureCode scanning / ESLint Enforce consistent linebreak style for operators Error
'||' should be placed at the beginning of the line.
|
||
| !Number.isFinite(startTimestamp) || | ||
Check failureCode scanning / ESLint Enforce consistent linebreak style for operators Error
'||' should be placed at the beginning of the line.
|
||
| startTimestamp <= 0 | ||
| ) { | ||
| startTimestamp = now | ||
| sessionStorage.setItem(START_KEY, String(startTimestamp)) | ||
| sessionStorage.setItem(VIDEO_KEY, videoId) | ||
| } | ||
|
|
||
| const mode = getMode(video, title.toLowerCase()) | ||
| const isPaused = video.paused | ||
|
|
||
| presenceData.details = isPaused ? `Paused (${mode})` : `Watching (${mode})` | ||
| presenceData.state = title | ||
| presenceData.smallImageKey = isPaused ? Assets.Pause : Assets.Play | ||
|
|
||
| // ⏱ TIMER | ||
| presenceData.startTimestamp = startTimestamp | ||
|
|
||
| // 🔥 PROGRESS BAR (REPLAY ONLY) | ||
| if (mode === "REPLAY" && isFinite(video.duration)) { | ||
Check failureCode scanning / ESLint Enforce the consistent use of either backticks, double, or single quotes Error
Strings must use singlequote.
Check failureCode scanning / ESLint Prefer `Number` static properties over global ones. Error
Prefer Number.isFinite over isFinite.
|
||
| presenceData.endTimestamp = | ||
Check failureCode scanning / ESLint Enforce consistent linebreak style for operators Error
'=' should be placed at the beginning of the line.
|
||
| startTimestamp + Math.floor(video.duration - video.currentTime) | ||
| } | ||
|
|
||
| presence.setActivity(presenceData) | ||
| }) | ||
Check failureCode scanning / ESLint Require or disallow newline at the end of files Error
Newline required at end of file but not found.
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this file from PR |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "extends": "../../../tsconfig.base.json", | ||
| "compilerOptions": { | ||
| "outDir": "./dist/" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this asset from PR