hideAppleMusic

This commit is contained in:
√(noham)²
2025-01-13 16:58:37 +01:00
parent f6fc111124
commit 63d86bef08
2 changed files with 47 additions and 34 deletions

View File

@@ -11,6 +11,7 @@ export type Parameters = {
hideProfile?: string;
hideActivity?: string;
hideSpotify?: string;
hideAppleMusic?: string;
hideClan?: string;
hideDecoration?: string;
ignoreAppId?: string;
@@ -22,36 +23,36 @@ export type Parameters = {
export type IParameterInfo = Array<
{ deprecated?: boolean } & (
| {
parameter: string;
type: "boolean";
title: string;
description?: string;
options?: {
defaultBool?: boolean;
};
}
parameter: string;
type: "boolean";
title: string;
description?: string;
options?: {
defaultBool?: boolean;
};
}
| {
parameter: string;
type: "string";
title: string;
description?: string;
options?: {
placeholder?: string;
omit?: string[];
};
}
parameter: string;
type: "string";
title: string;
description?: string;
options?: {
placeholder?: string;
omit?: string[];
};
}
| {
parameter: string;
type: "list";
title: string;
description?: string;
options: {
list: Array<{
name: string;
value: string;
}>;
};
}
parameter: string;
type: "list";
title: string;
description?: string;
options: {
list: Array<{
name: string;
value: string;
}>;
};
}
)
>;
@@ -174,6 +175,12 @@ export const PARAMETER_INFO: IParameterInfo = [
title: "Hide Spotify",
description: "Hides your Spotify activity only.",
},
{
parameter: "hideAppleMusic",
type: "boolean",
title: "Hide Apple Music",
description: "Hides your Apple Music activity only.",
},
{
parameter: "ignoreAppId",
type: "string",

View File

@@ -19,6 +19,7 @@ export type Parameters = {
hideProfile?: string;
hideActivity?: string;
hideSpotify?: string;
hideAppleMusic?: string;
hideClan?: string;
hideDecoration?: string;
ignoreAppId?: string;
@@ -75,6 +76,7 @@ async function renderCard(body: LanyardTypes.Root, params: Parameters): Promise<
let hideProfile = parseBool(params.hideProfile);
let hideActivity = params.hideActivity ?? "false";
let hideSpotify = parseBool(params.hideSpotify);
let hideAppleMusic = parseBool(params.hideAppleMusic);
let hideClan = parseBool(params.hideClan);
let hideDecoration = parseBool(params.hideDecoration);
let ignoreAppId = parseAppId(params.ignoreAppId);
@@ -150,10 +152,14 @@ async function renderCard(body: LanyardTypes.Root, params: Parameters): Promise<
if (data.activities[0] && data.activities[0].type === 4) userStatus = data.activities[0];
const activities = data.activities
// Filter only type 0
.filter(activity => activity.type === 0)
// Filter ignored app ID
.filter(activity => !ignoreAppId.includes(activity.application_id ?? ""));
.filter(activity => {
// Filter out Apple Music if hideAppleMusic is true
if (hideAppleMusic && activity.name === "Apple Music") {
return false;
}
// Filter only type 0 and respect ignored app IDs
return activity.type === 0 && !ignoreAppId.includes(activity.application_id ?? "");
});
// Take the highest one
activity = Array.isArray(activities) ? activities[0] : activities;
@@ -163,7 +169,7 @@ async function renderCard(body: LanyardTypes.Root, params: Parameters): Promise<
if (hideProfile) return "130";
if (hideActivity === "true") return "91";
if (hideActivity === "whenNotUsed" && !activity && !data.listening_to_spotify) return "91";
if (hideSpotify && data.listening_to_spotify) return "210";
if ((hideSpotify && data.listening_to_spotify) || (hideAppleMusic && activity?.name === "Apple Music")) return "210";
return "210";
};
@@ -172,7 +178,7 @@ async function renderCard(body: LanyardTypes.Root, params: Parameters): Promise<
if (hideProfile) return "120";
if (hideActivity === "true") return "81";
if (hideActivity === "whenNotUsed" && !activity && !data.listening_to_spotify) return "81";
if (hideSpotify && data.listening_to_spotify) return "200";
if ((hideSpotify && data.listening_to_spotify) || (hideAppleMusic && activity?.name === "Apple Music")) return "200";
return "200";
};