Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions websites/M/Monochrome/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://schemas.premid.app/metadata/1.16",
"apiVersion": 1,
"author": {
"id": "838652741965971517",
"name": "red_nael"
},
"service": "Monochrome",
"description": {
"en": "TODO"
},
"url": "monochrome.samidy.com",
"regExp": "^https?[:][/][/]([a-z0-9-]+[.])*monochrome[.]samidy[.]com[/]",
"version": "1.0.0",
"logo": "https://i.imgur.com/XHf3H8Y.png",
"thumbnail": "https://i.imgur.com/XHf3H8Y.png",
"color": "#000000",
"category": "music",
"tags": [
"music",
"tidal"
]
}
100 changes: 100 additions & 0 deletions websites/M/Monochrome/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// @ts-ignore

Check failure

Code scanning / ESLint

Disallow `@ts-<directive>` comments or require descriptions after directives Error

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free.

declare const Presence: any;

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.


// Static Asset Configuration

Check failure

Code scanning / ESLint

Disallow multiple empty lines Error

More than 1 blank line not allowed.
enum ActivityAssets {
Logo = 'https://i.imgur.com/XHf3H8Y.png',

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 2 spaces but found 4.
Play = 'https://i.imgur.com/ryNutI5.png',

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 2 spaces but found 4.
Pause = 'https://i.imgur.com/TlMwR5i.png'

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 2 spaces but found 4.
}

Check failure

Code scanning / ESLint

Require or disallow trailing commas Error

Missing trailing comma.

let presence;

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.

try {
presence = new Presence({

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 2 spaces but found 4.
clientId: '1459594619972096248'

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
});

Check failure

Code scanning / ESLint

Require or disallow trailing commas Error

Missing trailing comma.

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 2 spaces but found 4.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
} catch (error) {

Check failure

Code scanning / ESLint

Enforce consistent brace style for blocks Error

Closing curly brace appears on the same line as the subsequent block.

Check failure

Code scanning / ESLint

Disallow unused variables Error

'error' is defined but never used.
// Silent catch for production environments

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 2 spaces but found 4.
}

if (presence) {
presence.on('UpdateData', async () => {

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 2 spaces but found 4.

Check failure

Code scanning / ESLint

Disallow trailing whitespace at the end of lines Error

Trailing spaces not allowed.
// 1. DYNAMIC IMAGE LOGIC

Check failure

Code scanning / ESLint

Require or disallow padding within blocks Error

Block must not be padded by blank lines.

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
// Default to the static logo

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
let currentLargeImage: string = ActivityAssets.Logo;

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.

Check failure

Code scanning / ESLint

Disallow trailing whitespace at the end of lines Error

Trailing spaces not allowed.
// standard mediaSession check for high-res artwork

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
const artwork = navigator.mediaSession?.metadata?.artwork;

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.

if (artwork && artwork.length > 0) {

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
// Select the last image in the array (typically the highest resolution)

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.
const coverUrl = artwork[artwork.length - 1]?.src;

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
if (coverUrl) {

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.
currentLargeImage = coverUrl;

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 8 spaces but found 16.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
}

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.
}

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

// 2. INITIALIZE ACTIVITY DATA

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
// We create a fresh object every tick to avoid 'undefined' property issues

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
const presenceData: any = {

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
type: 2, // ActivityType.Listening

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.
largeImageKey: currentLargeImage,

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.
largeImageText: "Listening on Monochrome",

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.
// Default small icon (overwritten below if paused)

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.
smallImageKey: ActivityAssets.Play,

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.
smallImageText: "Playing"

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.
};

Check failure

Code scanning / ESLint

Require or disallow trailing commas Error

Missing trailing comma.

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.

// 3. TEXT STRATEGY (Browser Tab)

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
// Parses "Song - Artist" or "Song • Artist" from the document title

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
const tabTitle = document.title || "";

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
let separator = "";

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.

if (tabTitle.includes(' - ')) separator = " - ";

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

Check failure

Code scanning / ESLint

Newline after if Error

Expect newline after if

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
else if (tabTitle.includes(' • ')) separator = " • ";

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

Check failure

Code scanning / ESLint

Newline after if Error

Expect newline after if

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.

if (separator) {

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
const parts = tabTitle.split(separator);

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
presenceData.details = parts[0]?.trim() || "Unknown Song";

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
presenceData.state = parts.slice(1).join(separator).trim() || "Unknown Artist";

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
} else {

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

Check failure

Code scanning / ESLint

Enforce consistent brace style for blocks Error

Closing curly brace appears on the same line as the subsequent block.
// Fallback for non-standard titles

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.
presenceData.details = "Monochrome";

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
presenceData.state = "Listening...";

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
}

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

// 4. AUDIO STATUS & TIMESTAMPS

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
const mediaElement = document.querySelector('audio');

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.

if (mediaElement) {

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 4 spaces but found 8.
if (!mediaElement.paused) {

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 6 spaces but found 12.
// -- PLAYING STATE --

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 8 spaces but found 16.
presenceData.smallImageKey = ActivityAssets.Play;

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 8 spaces but found 16.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
presenceData.smallImageText = "Playing";

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 8 spaces but found 16.

Check failure

Code scanning / ESLint

Enforce the consistent use of either backticks, double, or single quotes Error

Strings must use singlequote.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.

// Calculate timestamps using native Date.now() for accuracy

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 8 spaces but found 16.
const now = Date.now();

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 8 spaces but found 16.

Check failure

Code scanning / ESLint

Require or disallow semicolons instead of ASI Error

Extra semicolon.
presenceData.startTimestamp = now - (mediaElement.currentTime * 1000);

Check failure

Code scanning / ESLint

Enforce consistent indentation Error

Expected indentation of 8 spaces but found 16.

// Only set endTimestamp if duration is finite and positive
if (mediaElement.duration && Number.isFinite(mediaElement.duration) && mediaElement.duration > 0) {
presenceData.endTimestamp = now + ((mediaElement.duration - mediaElement.currentTime) * 1000);
}
} else {
// -- PAUSED STATE --
presenceData.smallImageKey = ActivityAssets.Pause;
presenceData.smallImageText = "Paused";
// Note: We do not set timestamps here, effectively hiding the time bar
}

presence.setActivity(presenceData);
} else {
// Clear activity if no audio player is found
presence.setActivity({});
}
});
}
Loading