Skip to content

Commit 6969e44

Browse files
authored
feat(Anizium): add option to customize Activity name (#10297)
* feat(Anizium): Enhance presence buttons for watch and studio pages This commit improves the buttons for the Anizium presence. - On the watch page, a "View Anime" button is now added alongside the "View Episode" button, providing a direct link to the anime's main page. - On studio pages, a new "View Studio" button is now displayed. * feat(anizium): Add partner endpoint Introduces a new route handler for the '/partner' page in Anizium. * feat(anizium): Add privacy mode to settings Introduces a new "Privacy Mode" setting for the Anizium website. This feature allows users to hide anime and episode information from their Discord presence. The changes include: - Adding a `privacy` boolean to the `AniziumSettings` interface and `SETTINGS_CONFIG`. - Including the "Privacy Mode" setting in `metadata.json` with appropriate title, description, icon, and default value. - Implementing the privacy mode logic in `presence.ts` to display "Gizlilik Modu Aktif" when enabled. - Updating descriptions for existing settings to be more concise and accurate. * feat: Add option to customize presence name in Anizium This commit introduces a new setting, `usePresenceName`, which allows users to control whether the Rich Presence displays "Anizium" or the anime's actual title as the main presence name. Previously, the presence name was always "Anizium". With this change, users can now choose to see the anime's title directly in their Discord Rich Presence, providing a more informative experience. The `handleAnimePageUpdate` and `handleWatchingPageUpdate` functions have been modified to conditionally set the `name`, `details`, and `state` fields of the `presenceData` object based on the `usePresenceName` setting. A new entry for `usePresenceName` has also been added to the `SETTINGS_CONFIG` and `metadata.json` files, along with its corresponding type in `AniziumSettings`. * feat: Add conditional visibility to Anizium presence settings This commit introduces conditional visibility (`if` property) to several Anizium presence settings in `metadata.json`. The following settings will now only be visible when the `privacy` setting is `false`: - `showButtons` - `showPosters` - `watchingDetails` - `watchingState` - `showTimestamp` Additionally, `watchingDetails` and `watchingState` will only be visible when `usePresenceName` is also `true`. This change improves the user experience by only displaying relevant settings based on other configuration choices, reducing clutter and potential confusion. * feat: Add privacy setting for poster display Introduce a `privacy` setting to control the display of posters. When the `privacy` setting is enabled, posters will no longer be shown, even if `showPosters` is true. This provides users with more control over the information shared in their presence. * update version * feat: Remove state property for single episode and movie details in presence data
1 parent e7bd096 commit 6969e44

File tree

5 files changed

+124
-29
lines changed

5 files changed

+124
-29
lines changed

websites/A/Anizium/handlers/route.ts

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,22 @@ export class RouteHandlers {
202202
presenceData.state = 'İzlediklerim listesi görüntüleniyor'
203203
}
204204

205-
static handleStudioPage(presenceData: PresenceData): void {
205+
static handleStudioPage(presenceData: PresenceData, settings: AniziumSettings): void {
206206
presenceData.smallImageKey = Assets.Reading
207207
presenceData.details = 'Anizium'
208208

209209
const titleElement = document.querySelector('html > head > title')
210210
const pageTitle = titleElement?.textContent?.trim()
211211

212+
if (settings?.showButtons) {
213+
presenceData.buttons = [
214+
{
215+
label: 'Stüdyoyu Görüntüle',
216+
url: document.location.href,
217+
},
218+
219+
]
220+
}
212221
if (pageTitle && pageTitle !== 'Anizium - Türkçe Dublaj & 4K İzleme Platformu') {
213222
const studioName = pageTitle.replace(/ - Anizium$/, '').trim()
214223
presenceData.state = `${studioName} stüdyosunu görüntülüyor`
@@ -241,6 +250,11 @@ export class RouteHandlers {
241250
presenceData.state = 'Uygulamalar bölümünü görüntülüyor'
242251
}
243252

253+
static handlePartner(presenceData: PresenceData): void {
254+
presenceData.details = 'Anizium'
255+
presenceData.state = 'Partnerleri görüntülüyor'
256+
}
257+
244258
static handleWatchPageUpdate(presenceData: PresenceData, settings: AniziumSettings): void {
245259
const params = new URLSearchParams(document.location.search)
246260
const season = params.get('season')
@@ -255,37 +269,72 @@ export class RouteHandlers {
255269
episode,
256270
}
257271

258-
if (season && episode) {
272+
// If the setting is ON -> Title "Anizium"
273+
274+
if (settings.usePresenceName) {
275+
const combinedStateText = (season && episode)
276+
? this.formatString(settings.watchingState, placeholders)
277+
: 'Tek Bölüm'
278+
259279
presenceData.details = this.formatString(settings.watchingDetails, placeholders)
260-
presenceData.state = this.formatString(settings.watchingState, placeholders)
280+
presenceData.state = combinedStateText
261281
}
262282
else {
263-
const singleEpisodeState
264-
= settings.watchingState.includes('%season%')
265-
|| settings.watchingState.includes('%episode%')
266-
? 'Tek Bölüm'
267-
: settings.watchingState
283+
Object.assign(presenceData, { name: animeTitle })
268284

269-
presenceData.details = this.formatString(settings.watchingDetails, placeholders)
270-
presenceData.state = this.formatString(singleEpisodeState, placeholders)
285+
if (season && episode) {
286+
presenceData.details = `Sezon ${season}`
287+
presenceData.state = `Bölüm ${episode}`
288+
} // If the setting is OFF -> Title "Anime Name"
289+
290+
else {
291+
presenceData.details = 'Film / Tek Bölüm'
292+
delete presenceData.state
293+
}
271294
}
272295

273296
if (settings?.showButtons) {
274-
presenceData.buttons = [
275-
{
276-
label: 'Bölümü Görüntüle',
277-
url: document.location.href,
278-
},
279-
]
297+
const match = document.location.href.match(/watch\/(\d+)/)
298+
const animeId = match ? match[1] : null
299+
300+
const episodeButton = {
301+
label: 'Bölümü Görüntüle',
302+
url: document.location.href,
303+
}
304+
305+
if (animeId) {
306+
presenceData.buttons = [
307+
{
308+
label: 'Animeyi Görüntüle',
309+
url: `https://anizium.co/anime/${animeId}`,
310+
},
311+
episodeButton,
312+
]
313+
}
314+
else {
315+
presenceData.buttons = [episodeButton]
316+
}
280317
}
281318
}
282319

283320
static handleAnimePageUpdate(presenceData: PresenceData, settings: AniziumSettings): void {
284321
const pageTitle = document.querySelector('html > head > title')?.textContent || 'Loading'
322+
const cleanTitle = pageTitle.replace(/ - Anizium$/, '')
323+
const infoText = 'Anime detayları ve bölümleri görüntüleniyor'
324+
325+
// If the setting is ON -> Title "Anizium"
326+
if (settings.usePresenceName) {
327+
presenceData.details = cleanTitle
328+
presenceData.state = infoText
329+
}
330+
// If the setting is OFF -> Title "Anime Name"
331+
else {
332+
Object.assign(presenceData, { name: cleanTitle })
333+
presenceData.details = infoText
334+
delete presenceData.state
335+
}
285336

286-
presenceData.details = pageTitle.replace(/ - Anizium$/, '')
287337
presenceData.smallImageKey = Assets.Viewing
288-
presenceData.state = 'Anime detayları ve bölümleri görüntüleniyor'
289338

290339
if (settings?.showButtons) {
291340
presenceData.buttons = [

websites/A/Anizium/managers/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const SETTINGS_CONFIG: {
66
type: 'boolean' | 'number' | 'string'
77
defaultValue: any
88
}[] = [
9+
{ key: 'privacy', type: 'boolean', defaultValue: false },
10+
{ key: 'usePresenceName', type: 'boolean', defaultValue: true },
911
{ key: 'showButtons', type: 'boolean', defaultValue: true },
1012
{ key: 'showPosters', type: 'boolean', defaultValue: true },
1113
{ key: 'logoType', type: 'number', defaultValue: 0 },

websites/A/Anizium/metadata.json

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"www.anizium.co"
2424
],
2525
"regExp": "^https?[:][/][/]((www[.])?anizium[.]com|(www[.])?anizium[.]co)[/]",
26-
"version": "2.3.0",
26+
"version": "2.4.0",
2727
"logo": "https://cdn.rcd.gg/PreMiD/websites/A/Anizium/assets/logo.png",
2828
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/A/Anizium/assets/thumbnail.png",
2929
"color": "#b6eafd",
@@ -37,23 +37,45 @@
3737
"iframe": true,
3838
"iFrameRegExp": "https?:\\/\\/x\\.anizium\\.co\\/embed.*",
3939
"settings": [
40+
{
41+
"id": "privacy",
42+
"title": "Privacy Mode",
43+
"description": "Hides all anime and episode information from your presence.",
44+
"icon": "fad fa-user-secret",
45+
"value": false
46+
},
47+
{
48+
"id": "usePresenceName",
49+
"title": "Show Title as Presence",
50+
"icon": "fad fa-user-edit",
51+
"value": true,
52+
"if": {
53+
"privacy": false
54+
}
55+
},
4056
{
4157
"id": "showButtons",
4258
"title": "Show Buttons",
4359
"icon": "fas fa-compress-arrows-alt",
4460
"value": true,
45-
"description": "Shows/hides the 'View Episode' or 'View Anime' buttons on your Discord status."
61+
"description": "Toggles the 'View Episode' and 'View Anime' buttons in your presence.",
62+
"if": {
63+
"privacy": false
64+
}
4665
},
4766
{
4867
"id": "showPosters",
4968
"title": "Show Posters",
5069
"icon": "fas fa-image",
5170
"value": true,
52-
"description": "Toggles the display of anime and studio posters on your Discord status. If disabled, the Anizium logo will be shown instead."
71+
"description": "Toggles the display of anime posters in your presence. If disabled, the Anizium logo will be shown instead.",
72+
"if": {
73+
"privacy": false
74+
}
5375
},
5476
{
5577
"id": "logoType",
56-
"title": "Icon",
78+
"title": "Logo Type",
5779
"icon": "fad fa-images",
5880
"value": 0,
5981
"values": [
@@ -70,22 +92,34 @@
7092
"icon": "fas fa-comment-alt-edit",
7193
"value": "%anime_title%",
7294
"placeholder": "Available: %anime_title%, %season%, %episode%",
73-
"description": "Customize the first line of text on your Discord status when watching an anime."
95+
"description": "Customize the first line of text in your presence while watching.",
96+
"if": {
97+
"privacy": false,
98+
"usePresenceName": true
99+
}
74100
},
75101
{
76102
"id": "watchingState",
77103
"title": "Watching Details (Line 2)",
78104
"icon": "fas fa-comment-alt-edit",
79-
"value": "Sezon %season% | Bölüm %episode%",
105+
"value": "Season %season% | Episode %episode%",
80106
"placeholder": "Available: %anime_title%, %season%, %episode%",
81-
"description": "Customize the second line of text on your Discord status when watching an anime."
107+
"description": "Customize the second line of text in your presence while watching.",
108+
"if": {
109+
"privacy": false,
110+
"usePresenceName": true
111+
112+
}
82113
},
83114
{
84115
"id": "showTimestamp",
85-
"title": "Show Timestamps",
116+
"title": "Show Timestamp",
86117
"icon": "fad fa-stopwatch",
87118
"value": true,
88-
"description": "Shows/hides the elapsed and remaining time on your Discord status when watching an episode."
119+
"description": "Toggles the elapsed and remaining time of the episode in your presence.",
120+
"if": {
121+
"privacy": false
122+
}
89123
}
90124
]
91125
}

websites/A/Anizium/presence.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class AniziumPresence {
4343
const settings = this.settingsManager.currentSettings
4444

4545
const largeImage
46-
= settings?.showPosters && this.posterManager.posterUrl
46+
= (settings?.showPosters && !settings?.privacy) && this.posterManager.posterUrl
4747
? this.posterManager.posterUrl
4848
: this.settingsManager.getLogo()
4949

@@ -105,6 +105,13 @@ class AniziumPresence {
105105
const settings = this.settingsManager.currentSettings!
106106

107107
const presenceData = this.buildBasePresence()
108+
109+
if (settings?.privacy) {
110+
presenceData.details = 'Gizlilik Modu Aktif'
111+
presence.setActivity(presenceData)
112+
return
113+
}
114+
108115
const pathname = document.location.pathname
109116
const routePattern = Utils.getRoutePattern(pathname)
110117

@@ -124,11 +131,12 @@ class AniziumPresence {
124131
'/favorite-list': () => RouteHandlers.handleFavoriteList(presenceData),
125132
'/watch-list': () => RouteHandlers.handleWatchList(presenceData),
126133
'/watched-list': () => RouteHandlers.handleWatchedList(presenceData),
127-
'/studio': () => RouteHandlers.handleStudioPage(presenceData),
134+
'/studio': () => RouteHandlers.handleStudioPage(presenceData, settings),
128135
'/privacy-policy': () => RouteHandlers.handlePrivacyPolicy(presenceData),
129136
'/comment-policy': () => RouteHandlers.handleCommentPolicy(presenceData),
130137
'/tos': () => RouteHandlers.handleTos(presenceData),
131138
'/app': () => RouteHandlers.handleApp(presenceData),
139+
'/partner': () => RouteHandlers.handlePartner(presenceData),
132140

133141
// Dinamik routelar
134142
'/watch/': () => RouteHandlers.handleWatchPageUpdate(presenceData, settings),

websites/A/Anizium/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export enum Images {
77
}
88

99
export interface AniziumSettings {
10+
privacy: boolean
11+
usePresenceName: boolean
1012
showButtons: boolean
1113
showPosters: boolean
1214
logoType: number

0 commit comments

Comments
 (0)