diff --git a/build.js b/build.js index cda5202..27d2f3d 100644 --- a/build.js +++ b/build.js @@ -1,15 +1,15 @@ const esbuild = require("esbuild"); -const fs = require("fs"); -const path = require("path"); -const crypto = require("crypto"); -const repl = require("repl"); +const fs = require("node:fs"); +const path = require("node:path"); +const crypto = require("node:crypto"); +const repl = require("node:repl"); const plugins = fs.readdirSync("./plugins"); for (const plugin of plugins) { - let pluginPath = path.join("./plugins/", plugin); + const pluginPath = path.join("./plugins/", plugin); const pluginManifest = JSON.parse( - fs.readFileSync(path.join(pluginPath, "plugin.json")) + fs.readFileSync(path.join(pluginPath, "plugin.json")), ); const outfile = path.join(pluginPath, "dist/index.js"); @@ -17,7 +17,7 @@ for (const plugin of plugins) { esbuild .build({ entryPoints: [ - "./" + path.join(pluginPath, pluginManifest.main ?? "index.js"), + `./${path.join(pluginPath, pluginManifest.main ?? "index.js")}`, ], bundle: true, minify: true, @@ -25,7 +25,7 @@ for (const plugin of plugins) { // Make every node builtin external while still bundling for browsers. external: [ ...repl._builtinLibs, - ...repl._builtinLibs.map((m) => "node:" + m), + ...repl._builtinLibs.map((m) => `node:${m}`), "@neptune", "@plugin", ], @@ -44,10 +44,10 @@ for (const plugin of plugins) { description: pluginManifest.description, author: pluginManifest.author, hash: this.read(), - }) + }), ); - console.log("Built " + pluginManifest.name + "!"); + console.log(`Built ${pluginManifest.name}!`); }); }); } diff --git a/package.json b/package.json index 9473823..339edd7 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { - "name": "neptune-plugin-template", - "description": "A neptune plugin monorepo template", - "main": "index.js", - "scripts": { - "build": "node ./build.js" - }, - "devDependencies": { - "esbuild": "^0.18.20" - } + "name": "neptune-plugin-template", + "description": "A neptune plugin monorepo template", + "main": "index.js", + "scripts": { + "build": "node ./build.js" + }, + "devDependencies": { + "esbuild": "^0.18.20" + } } diff --git a/plugins/DiscordRPC/plugin.json b/plugins/DiscordRPC/plugin.json index 541d96d..e370f1b 100644 --- a/plugins/DiscordRPC/plugin.json +++ b/plugins/DiscordRPC/plugin.json @@ -1,6 +1,6 @@ { - "name": "Discord RPC", - "description": "An opinionated arRPC only Discord RPC. (forked from toonlink's plugin)", - "author": "wont-stream", - "main": "./src/index.js" + "name": "Discord RPC", + "description": "An opinionated arRPC only Discord RPC. (forked from toonlink's plugin)", + "author": "wont-stream", + "main": "./src/index.js" } diff --git a/plugins/DiscordRPC/src/index.js b/plugins/DiscordRPC/src/index.js index 3002fd9..f4202ee 100644 --- a/plugins/DiscordRPC/src/index.js +++ b/plugins/DiscordRPC/src/index.js @@ -5,143 +5,147 @@ const formatLongString = (s) => (s.length >= 128 ? `${s.slice(0, 125)}...` : s); let programaticPause = false; function getTrackVibrantColor() { - const sheets = document.styleSheets; - - for (let i = 0; i < sheets.length; i++) { - try { - const rules = sheets[i].cssRules; - - for (let j = 0; j < rules.length; j++) { - const rule = rules[j]; - - if (rule.selectorText === ":root") { - const styles = rule.style; - const trackVibrantColor = styles.getPropertyValue( - "--track-vibrant-color" - ); - if (trackVibrantColor) { - return trackVibrantColor.trim(); - } - } - } - } catch (e) { } - } - - return null; + const sheets = document.styleSheets; + + for (let i = 0; i < sheets.length; i++) { + try { + const rules = sheets[i].cssRules; + + for (let j = 0; j < rules.length; j++) { + const rule = rules[j]; + + if (rule.selectorText === ":root") { + const styles = rule.style; + const trackVibrantColor = styles.getPropertyValue( + "--track-vibrant-color", + ); + if (trackVibrantColor) { + return trackVibrantColor.trim(); + } + } + } + } catch (e) {} + } + + return null; } class WebSocketTransport { - constructor() { - this.ws = null; - this.tries = 0; - } - - async connect() { - const port = 6463 + (this.tries % 10); - this.tries += 1; - this.ws = new WebSocket( - `ws://localhost:${port}/?v=1&client_id=1288341778637918208` - ); - - this.ws.onopen = this.onOpen.bind(this); - - this.ws.onclose = this.onClose.bind(this); - - this.ws.onerror = this.onError.bind(this); - } - - onOpen() { - unloadables.push( - neptune.intercept("playbackControls/TIME_UPDATE", ([current]) => { - if (programaticPause) return; - const { item: currentlyPlaying, type: mediaType } = - neptune.currentMediaItem; - - // TODO: add video support - if (mediaType !== "track") return; - - const date = new Date(); - const now = (date.getTime() / 1000); - const remaining = date.setSeconds( - date.getSeconds() + (currentlyPlaying.duration - current) - ); - - const paused = - neptune.store.getState().playbackControls.playbackState === - "NOT_PLAYING"; - - this.ws.readyState === 1 && - this.send({ - cmd: "SET_ACTIVITY", - args: { - pid: 2094112, - activity: { - timestamps: { - ...(paused - ? {} - : { - start: now, - end: remaining, - }), - }, - type: 2, - name: formatLongString(currentlyPlaying.title), - details: formatLongString( - `by ${currentlyPlaying.artists.map((a) => a.name).join(", ")}` - ), - assets: { - large_image: `https://resources.tidal.com/images/${currentlyPlaying.album.cover - .split("-") - .join("/")}/80x80.jpg`, - large_text: `on ${formatLongString( - currentlyPlaying.album.title - )}`, - small_text: - `${getTrackVibrantColor()}|${neptune.currentMediaItem.item.id}`, - ...(paused - ? { - small_image: "paused-pause", - } - : {}), - }, - buttons: [{ label: "Play Song", url: `https://listen.tidal.com/track/${neptune.currentMediaItem.item.id}?u` }], - }, - }, - }); - }) - ); - - programaticPause = true; - neptune.actions.playbackControls.pause(); - programaticPause = false; - } - - onClose(event) { - if (!event.wasClean) { - return; - } - } - - onError() { - for (const u of unloadables) { - u(); - } - try { - this.ws.close(); - } catch { } // eslint-disable-line no-empty - - setTimeout(() => { - this.connect(); - }, 250); - } - - send(data) { - this.ws.send(JSON.stringify(data)); - } - - close() { - this.ws.close(); - } + constructor() { + this.ws = null; + this.tries = 0; + } + + async connect() { + const port = 6463 + (this.tries % 10); + this.tries += 1; + this.ws = new WebSocket( + `ws://localhost:${port}/?v=1&client_id=1288341778637918208`, + ); + + this.ws.onopen = this.onOpen.bind(this); + + this.ws.onclose = this.onClose.bind(this); + + this.ws.onerror = this.onError.bind(this); + } + + onOpen() { + unloadables.push( + neptune.intercept("playbackControls/TIME_UPDATE", ([current]) => { + if (programaticPause) return; + const { item: currentlyPlaying, type: mediaType } = + neptune.currentMediaItem; + + // TODO: add video support + if (mediaType !== "track") return; + + const date = new Date(); + const now = date.getTime() / 1000; + const remaining = date.setSeconds( + date.getSeconds() + (currentlyPlaying.duration - current), + ); + + const paused = + neptune.store.getState().playbackControls.playbackState === + "NOT_PLAYING"; + + this.ws.readyState === 1 && + this.send({ + cmd: "SET_ACTIVITY", + args: { + pid: 2094112, + activity: { + timestamps: { + ...(paused + ? {} + : { + start: now, + end: remaining, + }), + }, + type: 2, + name: formatLongString(currentlyPlaying.title), + details: formatLongString( + `by ${currentlyPlaying.artists.map((a) => a.name).join(", ")}`, + ), + assets: { + large_image: `https://resources.tidal.com/images/${currentlyPlaying.album.cover + .split("-") + .join("/")}/80x80.jpg`, + large_text: `on ${formatLongString( + currentlyPlaying.album.title, + )}`, + small_text: `${getTrackVibrantColor()}|${neptune.currentMediaItem.item.id}`, + ...(paused + ? { + small_image: "paused-pause", + } + : {}), + }, + buttons: [ + { + label: "Play Song", + url: `https://listen.tidal.com/track/${neptune.currentMediaItem.item.id}?u`, + }, + ], + }, + }, + }); + }), + ); + + programaticPause = true; + neptune.actions.playbackControls.pause(); + programaticPause = false; + } + + onClose(event) { + if (!event.wasClean) { + return; + } + } + + onError() { + for (const u of unloadables) { + u(); + } + try { + this.ws.close(); + } catch {} // eslint-disable-line no-empty + + setTimeout(() => { + this.connect(); + }, 250); + } + + send(data) { + this.ws.send(JSON.stringify(data)); + } + + close() { + this.ws.close(); + } } const ws = new WebSocketTransport(); @@ -149,13 +153,13 @@ const ws = new WebSocketTransport(); ws.connect(); export async function onUnload() { - for (const u of unloadables) { - u(); - } - - if (ws) { - try { - ws.close(); - } catch { } - } -} \ No newline at end of file + for (const u of unloadables) { + u(); + } + + if (ws) { + try { + ws.close(); + } catch {} + } +} diff --git a/plugins/Staging/plugin.json b/plugins/Staging/plugin.json index 073990f..49bebbe 100644 --- a/plugins/Staging/plugin.json +++ b/plugins/Staging/plugin.json @@ -1,6 +1,6 @@ { - "name": "Staging", - "description": "Redirect you to the staging version of the desktop app.", - "author": "wont-stream", - "main": "./src/index.js" + "name": "Staging", + "description": "Redirect you to the staging version of the desktop app.", + "author": "wont-stream", + "main": "./src/index.js" } diff --git a/plugins/Staging/src/index.js b/plugins/Staging/src/index.js index 2d1981a..1ffc0f7 100644 --- a/plugins/Staging/src/index.js +++ b/plugins/Staging/src/index.js @@ -1,8 +1,8 @@ if (location.href.includes("desktop.tidal.com")) { - location.href = location.href.replace( - "desktop.tidal.com", - "desktop.stage.tidal.com" - ); + location.href = location.href.replace( + "desktop.tidal.com", + "desktop.stage.tidal.com", + ); } export async function onUnload() {} diff --git a/theme/index.css b/theme/index.css index a70b006..ce3ae2f 100644 --- a/theme/index.css +++ b/theme/index.css @@ -1,59 +1,59 @@ :root { - --wave-color-solid-accent-fill: var(--track-vibrant-color); - --wave-color-solid-rainbow-blue-fill: var(--track-vibrant-color); - --wave-color-solid-rainbow-green-brighter: var(--track-vibrant-color); - --wave-color-solid-rainbow-green-dark: var(--track-vibrant-color); - --wave-color-solid-rainbow-green-darker: var(--track-vibrant-color); - --wave-color-solid-rainbow-green-darkest: var(--track-vibrant-color); - --wave-color-solid-rainbow-green-fill: var(--track-vibrant-color); - --wave-color-solid-rainbow-orange-fill: var(--track-vibrant-color); - --wave-color-solid-rainbow-purple-fill: var(--track-vibrant-color); - --wave-color-solid-rainbow-red-bright: var(--track-vibrant-color); - --wave-color-solid-rainbow-red-brighter: var(--track-vibrant-color); - --wave-color-solid-rainbow-red-dark: var(--track-vibrant-color); - --wave-color-solid-rainbow-red-darker: var(--track-vibrant-color); - --wave-color-solid-rainbow-red-darkest: var(--track-vibrant-color); - --wave-color-solid-rainbow-red-fill: var(--track-vibrant-color); - --wave-color-solid-rainbow-yellow-bright: var(--track-vibrant-color); - --wave-color-solid-rainbow-yellow-brighter: var(--track-vibrant-color); - --wave-color-solid-rainbow-yellow-dark: var(--track-vibrant-color); - --wave-color-solid-rainbow-yellow-darker: var(--track-vibrant-color); - --wave-color-solid-rainbow-yellow-darkest: var(--track-vibrant-color); - --wave-color-solid-rainbow-yellow-fill: var(--track-vibrant-color); - - --wave-color-solid-contrast-fill: var(--track-vibrant-color); - - --wave-color-solid-base-brighter: #030303; - --wave-color-opacity-base-brighter-ultra-thick: #030303; - - --user-profile-linear-gradient: linear-gradient( - 160deg, - var(--track-vibrant-color) 1.22%, - #0c0c0c 79.07% - ) !important; + --wave-color-solid-accent-fill: var(--track-vibrant-color); + --wave-color-solid-rainbow-blue-fill: var(--track-vibrant-color); + --wave-color-solid-rainbow-green-brighter: var(--track-vibrant-color); + --wave-color-solid-rainbow-green-dark: var(--track-vibrant-color); + --wave-color-solid-rainbow-green-darker: var(--track-vibrant-color); + --wave-color-solid-rainbow-green-darkest: var(--track-vibrant-color); + --wave-color-solid-rainbow-green-fill: var(--track-vibrant-color); + --wave-color-solid-rainbow-orange-fill: var(--track-vibrant-color); + --wave-color-solid-rainbow-purple-fill: var(--track-vibrant-color); + --wave-color-solid-rainbow-red-bright: var(--track-vibrant-color); + --wave-color-solid-rainbow-red-brighter: var(--track-vibrant-color); + --wave-color-solid-rainbow-red-dark: var(--track-vibrant-color); + --wave-color-solid-rainbow-red-darker: var(--track-vibrant-color); + --wave-color-solid-rainbow-red-darkest: var(--track-vibrant-color); + --wave-color-solid-rainbow-red-fill: var(--track-vibrant-color); + --wave-color-solid-rainbow-yellow-bright: var(--track-vibrant-color); + --wave-color-solid-rainbow-yellow-brighter: var(--track-vibrant-color); + --wave-color-solid-rainbow-yellow-dark: var(--track-vibrant-color); + --wave-color-solid-rainbow-yellow-darker: var(--track-vibrant-color); + --wave-color-solid-rainbow-yellow-darkest: var(--track-vibrant-color); + --wave-color-solid-rainbow-yellow-fill: var(--track-vibrant-color); + + --wave-color-solid-contrast-fill: var(--track-vibrant-color); + + --wave-color-solid-base-brighter: #030303; + --wave-color-opacity-base-brighter-ultra-thick: #030303; + + --user-profile-linear-gradient: linear-gradient( + 160deg, + var(--track-vibrant-color) 1.22%, + #0c0c0c 79.07% + ) !important; } #sidebar { - background: black; + background: black; } #footerPlayer { - background: transparent; + background: transparent; } #feedSidebar, [aria-label="Shuffle"], [data-test="recent-searches-container"], [data-test="query-suggestions"] { - background: #030303; + background: #030303; } [style*="rgb(255, 212, 50)"], [style*="rgb(51, 255, 238)"], [style*="rgb(249, 186, 122)"] { - color: var(--track-vibrant-color) !important; + color: var(--track-vibrant-color) !important; } .betaBadge { - display: none; + display: none; }