Browse Source

fix: random fixes

Sv443 11 months ago
parent
commit
6332a11b86
4 changed files with 57 additions and 34 deletions
  1. 5 9
      src/features/behavior.ts
  2. 26 2
      src/menu/menu_old.css
  3. 24 22
      src/menu/menu_old.ts
  4. 2 1
      src/siteEvents.ts

+ 5 - 9
src/features/behavior.ts

@@ -192,14 +192,10 @@ async function delRemSongData(watchID: string) {
 
 //#region disable darkreader
 
-/** Disables Dark Reader if it is enabled */
+/** Disables Dark Reader if it is present */
 export function disableDarkReader() {
-  if(document.querySelector(".darkreader")) {
-    const metaElem = document.createElement("meta");
-    metaElem.name = "darkreader-lock";
-    metaElem.classList.add("bytm-disable-darkreader");
-    document.head.appendChild(metaElem);
-
-    info("Sent hint to Dark Reader to disable itself");
-  }
+  const metaElem = document.createElement("meta");
+  metaElem.name = "darkreader-lock";
+  metaElem.classList.add("bytm-disable-darkreader");
+  document.head.appendChild(metaElem);
 }

+ 26 - 2
src/menu/menu_old.css

@@ -393,20 +393,44 @@
   margin-top: 30px;
 }
 
+.bytm-markdown-container ul li {
+  padding-left: 0px;
+}
+
+.bytm-markdown-container ul li::marker {
+  content: none;
+}
+
 .bytm-markdown-container ul li::before {
   content: "• ";
   font-weight: bolder;
 }
 
+.bytm-markdown-container ul li > ul li {
+  padding-left: 16px;
+}
+
+.bytm-markdown-container ul li > ul li::marker {
+  content: none;
+}
+
 .bytm-markdown-container ul li > ul li::before {
   white-space: pre-wrap;
-  content: "    • ";
+  content: "• ";
   font-weight: bolder;
 }
 
+.bytm-markdown-container ul li > ul li > ul li {
+  padding-left: 16px;
+}
+
+.bytm-markdown-container ul li > ul li > ul li::marker {
+  content: none;
+}
+
 .bytm-markdown-container ul li > ul li > ul li::before {
   white-space: pre-wrap;
-  content: "        • ";
+  content: "• ";
   font-weight: bolder;
 }
 

+ 24 - 22
src/menu/menu_old.ts

@@ -149,27 +149,27 @@ async function addCfgMenu() {
   const footerCont = document.createElement("div");
   footerCont.className = "bytm-menu-footer-cont";
 
-  const footerElemCont = document.createElement("div");
-
-  const footerElem = document.createElement("div");
-  footerElem.classList.add("bytm-menu-footer", "hidden");
-  footerElem.setAttribute("aria-hidden", "true");
-  footerElem.textContent = t("reload_hint");
-  footerElem.role = "alert";
-
-  const reloadElem = document.createElement("button");
-  reloadElem.classList.add("bytm-btn");
-  reloadElem.style.marginLeft = "10px";
-  reloadElem.textContent = t("reload_now");
-  reloadElem.ariaLabel = reloadElem.title = t("reload_tooltip");
-  reloadElem.addEventListener("click", () => {
+  const reloadFooterCont = document.createElement("div");
+
+  const reloadFooterEl = document.createElement("div");
+  reloadFooterEl.classList.add("bytm-menu-footer", "hidden");
+  reloadFooterEl.setAttribute("aria-hidden", "true");
+  reloadFooterEl.textContent = t("reload_hint");
+  reloadFooterEl.role = "alert";
+
+  const reloadTxtEl = document.createElement("button");
+  reloadTxtEl.classList.add("bytm-btn");
+  reloadTxtEl.style.marginLeft = "10px";
+  reloadTxtEl.textContent = t("reload_now");
+  reloadTxtEl.ariaLabel = reloadTxtEl.title = t("reload_tooltip");
+  reloadTxtEl.addEventListener("click", () => {
     closeCfgMenu();
     disableBeforeUnload();
     location.reload();
   });
 
-  footerElem.appendChild(reloadElem);
-  footerElemCont.appendChild(footerElem);
+  reloadFooterEl.appendChild(reloadTxtEl);
+  reloadFooterCont.appendChild(reloadFooterEl);
 
   const resetElem = document.createElement("button");
   resetElem.classList.add("bytm-btn");
@@ -212,7 +212,7 @@ async function addCfgMenu() {
   buttonsCont.appendChild(importElem);
   buttonsCont.appendChild(resetElem);
 
-  footerCont.appendChild(footerElemCont);
+  footerCont.appendChild(reloadFooterCont);
   footerCont.appendChild(buttonsCont);
 
 
@@ -220,7 +220,7 @@ async function addCfgMenu() {
   const featuresCont = document.createElement("div");
   featuresCont.id = "bytm-menu-opts";
 
-  const onCfgChange = async (key: keyof typeof defaultData, initialVal: number | boolean | Record<string, unknown>, newVal: number | boolean | Record<string, unknown>) => {
+  const onCfgChange = async (key: keyof typeof defaultData, initialVal: string | number | boolean | HotkeyObj, newVal: string | number | boolean | HotkeyObj) => {
     const fmt = (val: unknown) => typeof val === "object" ? JSON.stringify(val) : String(val);
     info(`Feature config changed at key '${key}', from value '${fmt(initialVal)}' to '${fmt(newVal)}'`);
 
@@ -242,12 +242,12 @@ async function addCfgMenu() {
     featInfo[key]?.change?.(key, initialVal, newVal);
 
     if(requiresReload) {
-      footerElem.classList.remove("hidden");
-      footerElem.setAttribute("aria-hidden", "false");
+      reloadFooterEl.classList.remove("hidden");
+      reloadFooterEl.setAttribute("aria-hidden", "false");
     }
     else if(!requiresReload) {
-      footerElem.classList.add("hidden");
-      footerElem.setAttribute("aria-hidden", "true");
+      reloadFooterEl.classList.add("hidden");
+      reloadFooterEl.setAttribute("aria-hidden", "true");
     }
 
     if(initLocale !== featConf.locale) {
@@ -265,6 +265,8 @@ async function addCfgMenu() {
     }
     else if(getLocale() !== featConf.locale)
       setLocale(featConf.locale);
+
+    siteEvents.emit("configOptionChanged", key, initialVal, newVal);
   };
 
   /** Call whenever the feature config is changed */

+ 2 - 1
src/siteEvents.ts

@@ -9,7 +9,7 @@ export interface SiteEventsMap {
   /** Emitted whenever the feature config is changed - initialization is not counted */
   configChanged: (config: FeatureConfig) => void;
   // TODO: implement
-  /** Emitted whenever a config option is changed - contains the old and the new values */
+  /** Emitted whenever a config option is changed - contains the old and new value */
   configOptionChanged: <TKey extends keyof FeatureConfig>(key: TKey, oldValue: FeatureConfig[TKey], newValue: FeatureConfig[TKey]) => void;
   /** Emitted whenever the config menu should be rebuilt, like when a config was imported */
   rebuildCfgMenu: (config: FeatureConfig) => void;
@@ -53,6 +53,7 @@ export const allSiteEvents = [
   "autoplayQueueChanged",
   "songTitleChanged",
   "watchIdChanged",
+  "fullscreenToggled",
 ] as const;
 
 /** EventEmitter instance that is used to detect changes to the site */