Prechádzať zdrojové kódy

feat: add new settings & update readme

Sv443 1 rok pred
rodič
commit
0a16e9a4e9

+ 10 - 4
README.md

@@ -1,9 +1,13 @@
-# BetterYTM
-Userscript that improves [YouTube Music](https://music.youtube.com/)
+<div style="text-align: center;" align="center">
 
 
+<h1><img src="./resources/icon/icon.png" /><br>BetterYTM</h1>
+
+Configurable layout and UX improvements for YouTube Music
+
+</div>
 <br>
 <br>
 
 
-## Features:
+### Features:
 - Input:
 - Input:
     - Use arrow keys to skip forward or backward by 10 seconds
     - Use arrow keys to skip forward or backward by 10 seconds
     - Switch between YouTube and YouTube Music on a video by pressing a hotkey (F9 by default)
     - Switch between YouTube and YouTube Music on a video by pressing a hotkey (F9 by default)
@@ -18,7 +22,9 @@ Userscript that improves [YouTube Music](https://music.youtube.com/)
 <br>
 <br>
 
 
 To toggle features on or off, install the userscript, then click the "BetterYTM" text under the logo to open the settings menu.  
 To toggle features on or off, install the userscript, then click the "BetterYTM" text under the logo to open the settings menu.  
-Note that the page needs to be reloaded for the changes to take effect.
+Note that the page needs to be reloaded for the changes to take effect.  
+  
+My work relies on donations, so if you like this userscript please consider [supporting me ❤️](https://github.com/sponsors/Sv443)
 
 
 <br><br>
 <br><br>
 
 

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2 - 2
dist/BetterYTM.user.js


+ 2 - 2
package.json

@@ -1,8 +1,8 @@
 {
 {
   "name": "betterytm",
   "name": "betterytm",
   "version": "1.0.0",
   "version": "1.0.0",
-  "description": "Configurable Layout and UX improvements for YouTube Music",
-  "description:de": "Konfigurierbare Layout- und UX-Verbesserungen für YouTube Music",
+  "description": "Configurable layout and UX improvements for YouTube Music",
+  "description:de": "Konfigurierbares Layout und UX-Verbesserungen für YouTube Music",
   "homepage": "https://github.com/Sv443/BetterYTM",
   "homepage": "https://github.com/Sv443/BetterYTM",
   "main": "./src/BetterYTM.user.ts",
   "main": "./src/BetterYTM.user.ts",
   "type": "module",
   "type": "module",

+ 3 - 3
src/BetterYTM.user.ts

@@ -3,7 +3,7 @@ import { dbg, info } from "./constants";
 import { getDomain } from "./utils";
 import { getDomain } from "./utils";
 import {
 import {
   // layout
   // layout
-  addMediaCtrlGeniusBtn, addQueueGeniusBtns, addWatermark,
+  addMediaCtrlGeniusBtn, addQueueButtons, addWatermark,
   preInitLayout, removeUpgradeTab, setVolSliderSize,
   preInitLayout, removeUpgradeTab, setVolSliderSize,
   setVolSliderStep,
   setVolSliderStep,
   // lyrics
   // lyrics
@@ -54,8 +54,8 @@ import {
         if(features.geniusLyrics)
         if(features.geniusLyrics)
           await addMediaCtrlGeniusBtn();
           await addMediaCtrlGeniusBtn();
 
 
-        if(features.lyricsButtonsOnSongQueue)
-          await addQueueGeniusBtns();
+        if(features.queueButtons)
+          await addQueueButtons();
 
 
         if(typeof features.volumeSliderSize === "number")
         if(typeof features.volumeSliderSize === "number")
           setVolSliderSize();
           setVolSliderSize();

+ 52 - 16
src/features/index.ts

@@ -5,49 +5,85 @@ export * from "./menu";
 
 
 /** Contains all possible features with their default values and other config */
 /** Contains all possible features with their default values and other config */
 export const featInfo = {
 export const featInfo = {
-  arrowKeySupport: { // category: input
+  //#SECTION input
+  arrowKeySupport: {
     desc: "Arrow keys skip forwards and backwards by 10 seconds",
     desc: "Arrow keys skip forwards and backwards by 10 seconds",
     type: "toggle",
     type: "toggle",
+    category: "input",
     default: true,
     default: true,
   },
   },
-  removeUpgradeTab: { // category: layout
-    desc: "Remove the \"Upgrade\" / YT Music Premium tab",
-    type: "toggle",
-    default: true,
-  },
-  switchBetweenSites: { // category: input
+  switchBetweenSites: {
     desc: "Add F9 as a hotkey to switch between the YT and YTM sites on a video / song",
     desc: "Add F9 as a hotkey to switch between the YT and YTM sites on a video / song",
     type: "toggle",
     type: "toggle",
+    category: "input",
     default: true,
     default: true,
   },
   },
-  geniusLyrics: { // category: lyrics
-    desc: "Add a button to the media controls to open the current song's lyrics on genius.com in a new tab",
-    type: "toggle",
-    default: true,
+  switchSitesHotkey: {
+    desc: "Which hotkey needs to be pressed to switch sites?",
+    type: "hotkey",
+    category: "input",
+    default: {
+      key: "F9",
+      shift: false,
+      ctrl: false,
+      meta: false,
+    },
   },
   },
-  lyricsButtonsOnSongQueue: { // category: lyrics
-    desc: "TODO: Add a lyrics button to each song in the queue (\"up next\" tab)",
+
+  //#SECTION layout
+  removeUpgradeTab: {
+    desc: "Remove the \"Upgrade\" / YT Music Premium tab",
     type: "toggle",
     type: "toggle",
+    category: "layout",
     default: true,
     default: true,
   },
   },
-  volumeSliderSize: { // category: layout
+  volumeSliderSize: {
     desc: "The width of the volume slider in pixels",
     desc: "The width of the volume slider in pixels",
     type: "number",
     type: "number",
+    category: "layout",
     min: 10,
     min: 10,
     max: 1000,
     max: 1000,
     step: 5,
     step: 5,
     default: 160,
     default: 160,
   },
   },
-  volumeSliderStep: { // category: layout
+  volumeSliderStep: {
     desc: "Volume slider sensitivity - the smaller this number, the finer the volume control",
     desc: "Volume slider sensitivity - the smaller this number, the finer the volume control",
     type: "slider",
     type: "slider",
+    category: "layout",
     min: 1,
     min: 1,
     max: 20,
     max: 20,
     default: 2,
     default: 2,
   },
   },
-  watermarkEnabled: { // category: layout
+  watermarkEnabled: {
     desc: "Show a BetterYTM watermark under the YTM logo",
     desc: "Show a BetterYTM watermark under the YTM logo",
     type: "toggle",
     type: "toggle",
+    category: "layout",
+    default: true,
+  },
+  anchorAroundThumbnail: {
+    desc: "TODO: Make it so middle clicking a song to open in a new tab is easier",
+    type: "toggle",
+    category: "layout",
+    default: true,
+  },
+  queueButtons: {
+    desc: "TODO: Add buttons while hovering over a song in a queue to quickly remove it or open its lyrics",
+    type: "toggle",
+    category: "layout",
+    default: true,
+  },
+  dismissPopup: {
+    desc: "TODO: Automatically dismisses the \"are you still there\" popup",
+    type: "toggle",
+    category: "layout",
+    default: true,
+  },
+
+  //#SECTION lyrics
+  geniusLyrics: {
+    desc: "Add a button to the media controls to open the current song's lyrics on genius.com in a new tab",
+    type: "toggle",
+    category: "lyrics",
     default: true,
     default: true,
   },
   },
 };
 };

+ 6 - 0
src/features/layout.ts

@@ -100,3 +100,9 @@ export function setVolSliderStep() {
 
 
   sliderElem.setAttribute("step", String(features.volumeSliderStep));
   sliderElem.setAttribute("step", String(features.volumeSliderStep));
 }
 }
+
+//#MARKER queue buttons
+
+export function addQueueButtons() {
+  void "TODO";
+}

+ 0 - 7
src/features/lyrics.ts

@@ -117,13 +117,6 @@ export async function addMediaCtrlGeniusBtn(): Promise<unknown> {
   obs.observe(songTitleElem, { attributes: true, attributeFilter: [ "title" ] });
   obs.observe(songTitleElem, { attributes: true, attributeFilter: [ "title" ] });
 }
 }
 
 
-
-/** Adds genius lyrics buttons to the song queue */
-export async function addQueueGeniusBtns()
-{
-  // TODO:
-}
-
 /** Returns the genius.com lyrics site URL for the current song */
 /** Returns the genius.com lyrics site URL for the current song */
 export async function getCurrentGeniusUrl() {
 export async function getCurrentGeniusUrl() {
   try {
   try {

+ 4 - 2
src/features/menu.ts

@@ -89,8 +89,9 @@ export async function addMenu() {
   featuresCont.style.flexDirection = "column";
   featuresCont.style.flexDirection = "column";
 
 
   /** Gets called whenever the feature config is changed */
   /** Gets called whenever the feature config is changed */
-  const confChanged = async (key: keyof typeof defaultFeatures, initialVal: number | boolean, newVal: number | boolean) => {
-    dbg && console.info(`BetterYTM: Feature config changed, key '${key}' from value '${initialVal}' to '${newVal}'`);
+  const confChanged = async (key: keyof typeof defaultFeatures, initialVal: number | boolean | Record<string, unknown>, newVal: number | boolean | Record<string, unknown>) => {
+    const fmt = (val: unknown) => typeof val === "object" ? JSON.stringify(val) : String(val);
+    dbg && console.info(`BetterYTM: Feature config changed, key '${key}' from value '${fmt(initialVal)}' to '${fmt(newVal)}'`);
 
 
     const featConf = { ...await getFeatures() };
     const featConf = { ...await getFeatures() };
 
 
@@ -302,6 +303,7 @@ export async function addMenu() {
   background-color: rgba(0, 0, 0, 0.6);
   background-color: rgba(0, 0, 0, 0.6);
 }
 }
 
 
+/* TODO:FIXME: needs better positioning (vw and vh === "big no no") */
 #betterytm-menu {
 #betterytm-menu {
   display: inline-block;
   display: inline-block;
   position: fixed;
   position: fixed;

+ 22 - 6
src/types.d.ts

@@ -3,20 +3,36 @@ export type Domain = "yt" | "ytm";
 
 
 /** Feature configuration */
 /** Feature configuration */
 export interface FeatureConfig {
 export interface FeatureConfig {
+  //#SECTION input
   /** Arrow keys skip forwards and backwards by 10 seconds */
   /** Arrow keys skip forwards and backwards by 10 seconds */
   arrowKeySupport: boolean;
   arrowKeySupport: boolean;
-  /** Remove the \"Upgrade\" / YT Music Premium tab */
-  removeUpgradeTab: boolean;
   /** Add F9 as a hotkey to switch between the YT and YTM sites on a video / song */
   /** Add F9 as a hotkey to switch between the YT and YTM sites on a video / song */
   switchBetweenSites: boolean;
   switchBetweenSites: boolean;
-  /** Add a button to the media controls to open the current song's lyrics on genius.com in a new tab */
-  geniusLyrics: boolean;
-  /** TODO: Add a lyrics button to each song in the queue (\"up next\" tab) */
-  lyricsButtonsOnSongQueue: boolean;
+  /** TODO: The hotkey that needs to be pressed to initiate the site switch */
+  switchSitesHotkey: {
+    key: string;
+    shift: boolean;
+    ctrl: boolean;
+    meta: boolean;
+  };
+
+  //#SECTION layout
+  /** Remove the \"Upgrade\" / YT Music Premium tab */
+  removeUpgradeTab: boolean;
   /** The width of the volume slider in pixels */
   /** The width of the volume slider in pixels */
   volumeSliderSize: number;
   volumeSliderSize: number;
   /** Volume slider sensitivity - the smaller this number, the finer the volume control */
   /** Volume slider sensitivity - the smaller this number, the finer the volume control */
   volumeSliderStep: number;
   volumeSliderStep: number;
   /** Show a BetterYTM watermark under the YTM logo */
   /** Show a BetterYTM watermark under the YTM logo */
   watermarkEnabled: boolean;
   watermarkEnabled: boolean;
+  /** TODO: Add an <a>nchor around song thumbnails */
+  anchorAroundThumbnail: boolean;
+  /** TODO: Add buttons while hovering over a song in a queue to quickly remove it or open its lyrics */
+  queueButtons: boolean;
+  /** TODO: Automatically dismisses the "are you still there" popup */
+  dismissPopup: boolean;
+
+  //#SECTION lyrics
+  /** Add a button to the media controls to open the current song's lyrics on genius.com in a new tab */
+  geniusLyrics: boolean;
 }
 }

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov