types.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. import type { NanoEmitter, Prettify } from "@sv443-network/userutils";
  2. import type * as consts from "./constants.js";
  3. import type { scriptInfo } from "./constants.js";
  4. import type { addSelectorListener } from "./observers.js";
  5. import type { getResourceUrl, getSessionId, getVideoTime, TrLocale, t, tp, fetchVideoVotes, onInteraction, getThumbnailUrl, getBestThumbnailUrl, getLocale, hasKey, hasKeyFor, getDomain, waitVideoElementReady, setInnerHtml, getCurrentMediaType, tl, tlp, formatNumber, getVideoElement, getVideoSelector, reloadTab } from "./utils/index.js";
  6. import type { SiteEventsMap } from "./siteEvents.js";
  7. import type { InterfaceEventsMap, getAutoLikeDataInterface, getFeaturesInterface, getPluginInfo, saveAutoLikeDataInterface, saveFeaturesInterface, setLocaleInterface } from "./interface.js";
  8. import type { fetchLyricsUrlTop, sanitizeArtists, sanitizeSong } from "./features/lyrics.js";
  9. import type { getLyricsCacheEntry } from "./features/lyricsCache.js";
  10. import type { showPrompt } from "./dialogs/prompt.js";
  11. import type { BytmDialog } from "./components/BytmDialog.js";
  12. import type { ExImDialog } from "./components/ExImDialog.js";
  13. import type { createHotkeyInput } from "./components/hotkeyInput.js";
  14. import type { createToggleInput } from "./components/toggleInput.js";
  15. import type { createCircularBtn } from "./components/circularButton.js";
  16. import type { createRipple } from "./components/ripple.js";
  17. import type { showIconToast, showToast } from "./components/toast.js";
  18. import resources from "../assets/resources.json" with { type: "json" };
  19. import locales from "../assets/locales.json" with { type: "json" };
  20. void ["type imports only", resources, locales];
  21. //#region other
  22. /** Custom CLI args passed to rollup */
  23. export type RollupArgs = Partial<{
  24. "config-mode": "development" | "production";
  25. "config-branch": "main" | "develop";
  26. "config-host": "greasyfork" | "github" | "openuserjs";
  27. "config-assetSource": "local" | "github" | "jsdelivr";
  28. "config-suffix": string;
  29. }>;
  30. // I know TS enums are impure but it doesn't really matter here, plus imo they are cooler than pure enums anyway
  31. export enum LogLevel {
  32. Debug,
  33. Info,
  34. }
  35. /** Which domain this script is currently running on */
  36. export type Domain = "yt" | "ytm";
  37. /** A selection option between one of the supported domains, or all of them */
  38. export type SiteSelection = Domain | "all";
  39. /** A selection option between one of the supported domains, or none of them */
  40. export type SiteSelectionOrNone = SiteSelection | "none";
  41. /** Key of a resource in `assets/resources.json` and extra keys defined by `tools/post-build.ts` */
  42. export type ResourceKey = keyof typeof resources["resources"] | `trans-${keyof typeof locales}`;
  43. /** Describes a single hotkey */
  44. export type HotkeyObj = {
  45. code: string,
  46. shift: boolean,
  47. ctrl: boolean,
  48. alt: boolean,
  49. };
  50. export type LyricsCacheEntry = {
  51. artist: string;
  52. song: string;
  53. url: string;
  54. viewed: number;
  55. added: number;
  56. };
  57. export type AutoLikeData = {
  58. channels: {
  59. /** 24-character channel ID or user ID including the @ prefix */
  60. id: string;
  61. /** Channel name (for display purposes only) */
  62. name: string;
  63. /** Whether the channel should be auto-liked */
  64. enabled: boolean;
  65. }[];
  66. };
  67. export type RYDVotesObj = {
  68. /** The watch ID of the video */
  69. id: string;
  70. /** ISO timestamp of when the video was uploaded */
  71. dateCreated: string;
  72. /** Amount of likes */
  73. likes: number;
  74. /** Amount of dislikes */
  75. dislikes: number;
  76. /** Like to dislike ratio from 0.0 to 5.0 */
  77. rating: number;
  78. /** Amount of views */
  79. viewCount: number;
  80. /** Whether the video was deleted */
  81. deleted: boolean;
  82. };
  83. export type VideoVotesObj = {
  84. /** The watch ID of the video */
  85. id: string;
  86. /** Amount of likes */
  87. likes: number;
  88. /** Amount of dislikes */
  89. dislikes: number;
  90. /** Like to dislike ratio from 0.0 to 5.0 */
  91. rating: number;
  92. /** Timestamp of when the data was fetched */
  93. timestamp: number;
  94. };
  95. export type NumberLengthFormat = "short" | "long";
  96. export type ColorLightnessPref = "darker" | "normal" | "lighter";
  97. //#region global
  98. /** All properties of the `unsafeWindow.BYTM` object (also called "plugin interface") */
  99. export type BytmObject =
  100. {
  101. [key: string]: unknown;
  102. locale: TrLocale;
  103. logLevel: LogLevel;
  104. }
  105. // information from the userscript header
  106. & typeof scriptInfo
  107. // certain variables from `src/constants.ts`
  108. & Pick<typeof consts, "mode" | "branch" | "host" | "buildNumber" | "initialParams" | "compressionFormat" | "sessionStorageAvailable" | "scriptInfo">
  109. // global functions exposed through the interface in `src/interface.ts`
  110. & InterfaceFunctions
  111. // others
  112. & {
  113. NanoEmitter: NanoEmitter;
  114. BytmDialog: typeof BytmDialog;
  115. ExImDialog: typeof ExImDialog;
  116. // the entire UserUtils library
  117. UserUtils: typeof import("@sv443-network/userutils");
  118. // the entire compare-versions library
  119. compareVersions: typeof import("compare-versions");
  120. };
  121. export type TTPolicy = {
  122. createHTML: (dirty: string) => string;
  123. };
  124. declare global {
  125. interface Window {
  126. // to see the expanded type, install the VS Code extension "MylesMurphy.prettify-ts" and hover over the property below
  127. // alternatively navigate with ctrl+click to find the types
  128. BYTM: BytmObject;
  129. // polyfill for the new Trusted Types API
  130. trustedTypes: {
  131. createPolicy(name: string, policy: TTPolicy): TTPolicy;
  132. };
  133. }
  134. }
  135. //#region plugins
  136. /**
  137. * Intents (permissions) BYTM has to grant your plugin for it to be able to access certain features.
  138. * TODO: this feature is unfinished, but you should still specify the intents your plugin needs.
  139. * Never request more permissions than you need, as this is a bad practice and can lead to your plugin being rejected.
  140. */
  141. export enum PluginIntent {
  142. /** Plugin can read the feature configuration */
  143. ReadFeatureConfig = 1,
  144. /** Plugin can write to the feature configuration */
  145. WriteFeatureConfig = 2,
  146. /** Plugin has access to hidden config values */
  147. SeeHiddenConfigValues = 4,
  148. /** Plugin can write to the lyrics cache */
  149. WriteLyricsCache = 8,
  150. /** Plugin can add new translations and overwrite existing ones */
  151. WriteTranslations = 16,
  152. /** Plugin can create modal dialogs */
  153. CreateModalDialogs = 32,
  154. /** Plugin can read auto-like data */
  155. ReadAutoLikeData = 64,
  156. /** Plugin can write to auto-like data */
  157. WriteAutoLikeData = 128,
  158. }
  159. /** Result of a plugin registration */
  160. export type PluginRegisterResult = {
  161. /** Public info about the registered plugin */
  162. info: PluginInfo;
  163. /** NanoEmitter instance for plugin events - see {@linkcode PluginEventMap} for a list of events */
  164. events: NanoEmitter<PluginEventMap>;
  165. /** Authentication token for the plugin to use in certain restricted function calls */
  166. token: string;
  167. }
  168. /** Minimal object that describes a plugin - this is all info the other installed plugins can see */
  169. export type PluginInfo = {
  170. /** Name of the plugin */
  171. name: string;
  172. /**
  173. * Adding the namespace and the name property makes the unique identifier for a plugin.
  174. * If one exists with the same name and namespace as this plugin, it may be overwritten at registration.
  175. * I recommend to set this value to a URL pointing to your homepage, or the author's username.
  176. */
  177. namespace: string;
  178. /** Version of the plugin as a semver-compliant string */
  179. version: string;
  180. };
  181. /** Minimum part of the PluginDef object needed to make up the resolvable plugin identifier */
  182. export type PluginDefResolvable = PluginDef | { plugin: Pick<PluginDef["plugin"], "name" | "namespace"> };
  183. /** An object that describes a BYTM plugin */
  184. export type PluginDef = {
  185. plugin: PluginInfo & {
  186. /**
  187. * Descriptions of at least en-US and optionally any other locale supported by BYTM.
  188. * When an untranslated locale is set, the description will default to the value of en-US
  189. */
  190. description: Partial<Record<keyof typeof locales, string>> & {
  191. "en-US": string;
  192. };
  193. /** URL to the plugin's icon - recommended size: 48x48 to 128x128 */
  194. iconUrl?: string;
  195. license?: {
  196. /** License name */
  197. name: string;
  198. /** URL to the license text */
  199. url: string;
  200. };
  201. /** Homepage URLs for the plugin */
  202. homepage: {
  203. /** URL to the plugin's source code (i.e. Git repo) - closed source plugins are not officially accepted at the moment. */
  204. source: string;
  205. /** Any other homepage URL */
  206. other?: string;
  207. /** URL to the plugin's bug tracker page, like GitHub issues */
  208. bug?: string;
  209. /** URL to the plugin's GreasyFork page */
  210. greasyfork?: string;
  211. /** URL to the plugin's OpenUserJS page */
  212. openuserjs?: string;
  213. };
  214. };
  215. /** Intents (permissions) BYTM has to grant the plugin for it to work - use bitwise OR to combine multiple intents */
  216. intents?: number;
  217. /** Info about the plugin contributors */
  218. contributors?: Array<{
  219. /** Name of this contributor */
  220. name: string;
  221. /** (optional) Email address of this contributor */
  222. email?: string;
  223. /** (optional) URL to this plugin contributor's homepage / GitHub profile */
  224. url?: string;
  225. }>;
  226. };
  227. /** All events that are dispatched to plugins individually, including everything in {@linkcode SiteEventsMap} and {@linkcode InterfaceEventsMap} - these don't have a prefix since they can't conflict with other events */
  228. export type PluginEventMap =
  229. // These are emitted on each plugin individually, with individual data:
  230. & {
  231. /** Emitted when the plugin is fully registered on BYTM's side and can use authenticated API calls */
  232. pluginRegistered: (info: PluginInfo) => void;
  233. }
  234. // These are emitted on every plugin simultaneously, with the same or similar data:
  235. & SiteEventsMap
  236. & InterfaceEventsMap;
  237. /** A plugin in either the queue or registered map */
  238. export type PluginItem = Prettify<
  239. & {
  240. def: PluginDef;
  241. }
  242. & Pick<PluginRegisterResult, "events">
  243. >;
  244. //#region plugin interface
  245. /** All functions exposed by the interface on the global `BYTM` object */
  246. export type InterfaceFunctions = {
  247. // meta:
  248. /** 🔒 Checks if the plugin with the given name and namespace is registered and returns an info object about it */
  249. getPluginInfo: typeof getPluginInfo;
  250. // bytm-specific:
  251. /** Returns the current domain as a constant string representation */
  252. getDomain: typeof getDomain;
  253. /**
  254. * Returns the URL of a resource as defined in `assets/resources.json`
  255. * There are also some resources like translation files that get added by `tools/post-build.ts`
  256. *
  257. * The returned URL is a `blob:` URL served up by the userscript extension
  258. * This makes the resource fast to fetch and also prevents CORS issues
  259. */
  260. getResourceUrl: typeof getResourceUrl;
  261. /** Returns the unique session ID for the current tab */
  262. getSessionId: typeof getSessionId;
  263. /** Smarter version of `location.reload()` that remembers video time and volume and makes other features like initial tab volume stand down if used */
  264. reloadTab: typeof reloadTab;
  265. // dom:
  266. /** Sets the innerHTML property of the provided element to a sanitized version of the provided HTML string */
  267. setInnerHtml: typeof setInnerHtml;
  268. /** Adds a listener to one of the already present SelectorObserver instances */
  269. addSelectorListener: typeof addSelectorListener;
  270. /** Registers accessible interaction listeners (click, enter, space) on the provided element */
  271. onInteraction: typeof onInteraction;
  272. /**
  273. * Returns the current video time (on both YT and YTM)
  274. * In case it can't be determined on YT, mouse movement is simulated to bring up the video time
  275. * In order for that edge case not to error out, the function would need to be called in response to a user interaction event (e.g. click) due to the strict autoplay policy in browsers
  276. */
  277. getVideoTime: typeof getVideoTime;
  278. /** Returns the thumbnail URL for the provided video ID and thumbnail quality */
  279. getThumbnailUrl: typeof getThumbnailUrl;
  280. /** Returns the thumbnail URL with the best quality for the provided video ID */
  281. getBestThumbnailUrl: typeof getBestThumbnailUrl;
  282. /** Resolves the returned promise when the video element is queryable in the DOM */
  283. waitVideoElementReady: typeof waitVideoElementReady;
  284. /** Returns the video element on the current page for both YTM and YT - returns null if it couldn't be found */
  285. getVideoElement: typeof getVideoElement;
  286. /** Returns the CSS selector to the video element for both YTM and YT */
  287. getVideoSelector: typeof getVideoSelector;
  288. /** (On YTM only) returns the current media type (video or song) */
  289. getCurrentMediaType: typeof getCurrentMediaType;
  290. // translations:
  291. /** 🔒 Sets the locale for all new translations */
  292. setLocale: typeof setLocaleInterface;
  293. /** Returns the current locale */
  294. getLocale: typeof getLocale;
  295. /** Returns whether a translation key exists for the set locale */
  296. hasKey: typeof hasKey;
  297. /** Returns whether a translation key exists for the provided locale */
  298. hasKeyFor: typeof hasKeyFor;
  299. /** Returns the translation for the provided translation key and currently set locale (check the files in the folder `assets/translations`) */
  300. t: typeof t;
  301. /** Returns the translation for the provided translation key, including pluralization identifier and set locale (check the files in the folder `assets/translations`) */
  302. tp: typeof tp;
  303. /** Returns the translation for the provided translation key and provided locale (check the files in the folder `assets/translations`) */
  304. tl: typeof tl;
  305. /** Returns the translation for the provided translation key, including pluralization identifier and provided locale (check the files in the folder `assets/translations`) */
  306. tlp: typeof tlp;
  307. // feature config:
  308. /** 🔒 Returns the current feature configuration */
  309. getFeatures: typeof getFeaturesInterface;
  310. /** 🔒 Overwrites the feature configuration with the provided one */
  311. saveFeatures: typeof saveFeaturesInterface;
  312. /** Returns the default feature configuration */
  313. getDefaultFeatures: () => FeatureConfig;
  314. // lyrics:
  315. /** Sanitizes the provided artist string - this needs to be done before calling other lyrics related functions! */
  316. sanitizeArtists: typeof sanitizeArtists;
  317. /** Sanitizes the provided song title string - this needs to be done before calling other lyrics related functions! */
  318. sanitizeSong: typeof sanitizeSong;
  319. /** Fetches the lyrics URL of the top search result for the provided song and artist. Before a request is sent, the cache is checked for a match. */
  320. fetchLyricsUrlTop: typeof fetchLyricsUrlTop;
  321. /** Returns the lyrics cache entry for the provided song and artist, if there is one. Never sends a request on its own. */
  322. getLyricsCacheEntry: typeof getLyricsCacheEntry;
  323. // auto-like:
  324. /** 🔒 Returns the current auto-like data */
  325. getAutoLikeData: typeof getAutoLikeDataInterface;
  326. /** 🔒 Overwrites the auto-like data */
  327. saveAutoLikeData: typeof saveAutoLikeDataInterface;
  328. /** Returns the votes for the provided video ID from the ReturnYoutubeDislike API */
  329. fetchVideoVotes: typeof fetchVideoVotes;
  330. // components:
  331. /** Creates a new hotkey input component */
  332. createHotkeyInput: typeof createHotkeyInput;
  333. /** Creates a new toggle input component */
  334. createToggleInput: typeof createToggleInput;
  335. /** Creates a new circular button component */
  336. createCircularBtn: typeof createCircularBtn;
  337. /** Creates a new ripple effect on the provided element or creates an empty element that has the effect */
  338. createRipple: typeof createRipple;
  339. /** Shows a toast with the provided text */
  340. showToast: typeof showToast;
  341. /** Shows a toast with the provided text and an icon */
  342. showIconToast: typeof showIconToast;
  343. /** Shows a styled confirm() or alert() dialog with the provided message */
  344. showPrompt: typeof showPrompt;
  345. // other:
  346. /** Formats a number to a string using the configured locale and configured or passed number notation */
  347. formatNumber: typeof formatNumber;
  348. };
  349. //#region feature defs
  350. /** Feature identifier */
  351. export type FeatureKey = keyof FeatureConfig;
  352. /** Feature category identifier */
  353. export type FeatureCategory =
  354. | "layout"
  355. | "volume"
  356. | "songLists"
  357. | "behavior"
  358. | "input"
  359. | "lyrics"
  360. | "integrations"
  361. | "plugins"
  362. | "general";
  363. type SelectOption = {
  364. value: string | number;
  365. label: string;
  366. };
  367. type FeatureTypeProps = ({
  368. type: "toggle";
  369. default: boolean;
  370. } & FeatureFuncProps)
  371. | ({
  372. type: "number";
  373. default: number;
  374. min: number;
  375. max?: number;
  376. step?: number;
  377. unit?: string | ((val: number) => string);
  378. } & FeatureFuncProps)
  379. | ({
  380. type: "select";
  381. default: string | number;
  382. options: SelectOption[] | (() => SelectOption[]);
  383. } & FeatureFuncProps)
  384. | ({
  385. type: "slider";
  386. default: number;
  387. min: number;
  388. max: number;
  389. step?: number;
  390. unit?: string | ((val: number) => string);
  391. } & FeatureFuncProps)
  392. | ({
  393. type: "hotkey";
  394. default: HotkeyObj;
  395. } & FeatureFuncProps)
  396. | ({
  397. type: "text";
  398. default: string;
  399. normalize?: (val: string) => string;
  400. } & FeatureFuncProps)
  401. | {
  402. type: "button";
  403. default?: undefined;
  404. click: () => Promise<void | unknown> | void | unknown;
  405. }
  406. type FeatureFuncProps = (
  407. {
  408. /** Whether the feature requires a page reload to take effect */
  409. reloadRequired: false;
  410. /** Called to instantiate the feature on the page */
  411. enable: (featCfg: FeatureConfig) => void,
  412. }
  413. | {
  414. /** Whether the feature requires a page reload to take effect */
  415. reloadRequired?: true;
  416. /** Called to instantiate the feature on the page */
  417. enable?: undefined;
  418. }
  419. ) & (
  420. {
  421. /** Called to remove all traces of the feature from the page and memory (includes event listeners) */
  422. disable?: (feats: FeatureConfig) => void,
  423. }
  424. | {
  425. /** Called to update the feature's behavior when the config changes */
  426. change?: (key: FeatureKey, initialVal: number | boolean | Record<string, unknown>, newVal: number | boolean | Record<string, unknown>) => void,
  427. }
  428. );
  429. /**
  430. * The feature info object that contains all properties necessary to construct the config menu and the feature config object.
  431. * All values are loosely typed so try to only use this via `const myObj = {} satisfies FeatureInfo;`
  432. * For full type safety, use `typeof featInfo` (from `src/features/index.ts`) instead.
  433. */
  434. export type FeatureInfo = Record<
  435. keyof FeatureConfig,
  436. {
  437. category: FeatureCategory;
  438. /**
  439. * HTML string that will be the help text for this feature
  440. * Specifying a function is useful for pluralizing or inserting values into the translation at runtime
  441. */
  442. helpText?: string | (() => string);
  443. /** Whether the value should be hidden in the config menu and from plugins */
  444. valueHidden?: boolean;
  445. /** Transformation function called before the value is rendered in the config menu */
  446. renderValue?: (value: string) => string | Promise<string>;
  447. /** HTML string that is appended to the end of a feature's text description */
  448. textAdornment?: () => (Promise<string | undefined> | string | undefined);
  449. /** Whether to only show this feature when advanced mode is activated (default false) */
  450. advanced?: boolean;
  451. }
  452. & FeatureTypeProps
  453. >;
  454. //#region feature config
  455. /** Feature configuration object, as saved in memory and persistent storage */
  456. export interface FeatureConfig {
  457. //#region layout
  458. /** Show a BetterYTM watermark under the YTM logo */
  459. watermarkEnabled: boolean;
  460. /** Remove the "si" tracking parameter from links in the share menu? */
  461. removeShareTrackingParam: boolean;
  462. /** On which sites to remove the "si" tracking parameter from links in the share menu */
  463. removeShareTrackingParamSites: SiteSelection;
  464. /** Enable skipping to a specific time in the video by pressing a number key (0-9) */
  465. numKeysSkipToTime: boolean;
  466. /** Fix spacing issues in the layout */
  467. fixSpacing: boolean;
  468. /** Where to show a thumbnail overlay over the video element and whether to show it at all */
  469. thumbnailOverlayBehavior: "never" | "videosOnly" | "songsOnly" | "always";
  470. /** Whether to show a button to toggle the thumbnail overlay in the media controls */
  471. thumbnailOverlayToggleBtnShown: boolean;
  472. /** Whether to show an indicator on the thumbnail overlay when it is active */
  473. thumbnailOverlayShowIndicator: boolean;
  474. /** The opacity of the thumbnail overlay indicator element */
  475. thumbnailOverlayIndicatorOpacity: number;
  476. /** How to fit the thumbnail overlay image */
  477. thumbnailOverlayImageFit: "cover" | "contain" | "fill";
  478. /** Hide the cursor when it's idling on the video element for a while */
  479. hideCursorOnIdle: boolean;
  480. /** Delay in seconds after which the cursor should be hidden */
  481. hideCursorOnIdleDelay: number;
  482. /** Whether to fix various issues in the layout when HDR is supported and active */
  483. fixHdrIssues: boolean;
  484. /** Whether to show the like/dislike ratio on the currently playing song */
  485. showVotes: boolean;
  486. /** Which format to use for the like/dislike ratio on the currently playing song */
  487. numbersFormat: NumberLengthFormat;
  488. //#region volume
  489. /** Add a percentage label to the volume slider */
  490. volumeSliderLabel: boolean;
  491. /** The width of the volume slider in pixels */
  492. volumeSliderSize: number;
  493. /** Volume slider sensitivity - the smaller this number, the finer the volume control */
  494. volumeSliderStep: number;
  495. /** Volume slider scroll wheel sensitivity */
  496. volumeSliderScrollStep: number;
  497. /** Whether the volume should be locked to the same level across all tabs (changing in one changes in all others too) */
  498. volumeSharedBetweenTabs: boolean;
  499. /** Whether to set an initial volume level for each new session */
  500. setInitialTabVolume: boolean;
  501. /** The initial volume level to set for each new session */
  502. initialTabVolumeLevel: number;
  503. //#region song lists
  504. /** Add a button to each song in the queue to quickly open its lyrics page */
  505. lyricsQueueButton: boolean;
  506. /** Add a button to each song in the queue to quickly remove it */
  507. deleteFromQueueButton: boolean;
  508. /** Where to place the buttons in the queue */
  509. listButtonsPlacement: "queueOnly" | "everywhere";
  510. /** Add a button above the queue to scroll to the currently playing song */
  511. scrollToActiveSongBtn: boolean;
  512. /** Add a button above the queue to clear it */
  513. clearQueueBtn: boolean;
  514. //#region behavior
  515. /** Whether to completely disable the popup that sometimes appears before leaving the site */
  516. disableBeforeUnloadPopup: boolean;
  517. /** After how many milliseconds to close permanent toasts */
  518. closeToastsTimeout: number;
  519. /** Remember the last song's time when reloading or restoring the tab */
  520. rememberSongTime: boolean;
  521. /** Where to remember the song time */
  522. rememberSongTimeSites: SiteSelection;
  523. /** Time in seconds to remember the song time for */
  524. rememberSongTimeDuration: number;
  525. /** Time in seconds to subtract from the remembered song time */
  526. rememberSongTimeReduction: number;
  527. /** Minimum time in seconds the song needs to be played before it is remembered */
  528. rememberSongTimeMinPlayTime: number;
  529. /** Whether the above queue button container should use sticky positioning */
  530. aboveQueueBtnsSticky: boolean;
  531. //#region input
  532. /** Arrow keys skip forwards and backwards */
  533. arrowKeySupport: boolean;
  534. /** By how many seconds to skip when pressing the arrow keys */
  535. arrowKeySkipBy: number;
  536. /** Add a hotkey to switch between the YT and YTM sites on a video / song */
  537. switchBetweenSites: boolean;
  538. /** The hotkey that needs to be pressed to initiate the site switch */
  539. switchSitesHotkey: HotkeyObj;
  540. /** Make it so middle clicking a song to open it in a new tab (through thumbnail and song title) is easier */
  541. anchorImprovements: boolean;
  542. /** Whether to auto-like all played videos of configured channels */
  543. autoLikeChannels: boolean;
  544. /** Whether to show toggle buttons on the channel page to enable/disable auto-liking for that channel */
  545. autoLikeChannelToggleBtn: boolean;
  546. // TODO(v2.2):
  547. // /** Whether to show a toggle button in the media controls to enable/disable auto-liking for those channel(s) */
  548. // autoLikePlayerBarToggleBtn: boolean;
  549. /** How long to wait after a video has started playing to auto-like it */
  550. autoLikeTimeout: number;
  551. /** Whether to show a toast when a video is auto-liked */
  552. autoLikeShowToast: boolean;
  553. /** Opens the auto-like channels management dialog */
  554. autoLikeOpenMgmtDialog: undefined;
  555. //#region lyrics
  556. /** Add a button to the media controls to open the current song's lyrics on genius.com in a new tab */
  557. geniusLyrics: boolean;
  558. /** Whether to show an error when no lyrics were found */
  559. errorOnLyricsNotFound: boolean;
  560. /** Base URL to use for GeniURL */
  561. geniUrlBase: string;
  562. /** Token to use for GeniURL */
  563. geniUrlToken: string;
  564. /** Max size of lyrics cache */
  565. lyricsCacheMaxSize: number;
  566. /** Max TTL of lyrics cache entries, in ms */
  567. lyricsCacheTTL: number;
  568. /** Button to clear lyrics cache */
  569. clearLyricsCache: undefined;
  570. // /** Whether to use advanced filtering when searching for lyrics (exact, exact-ish) */
  571. // advancedLyricsFilter: boolean;
  572. //#region integrations
  573. /** On which sites to disable Dark Reader - does nothing if the extension is not installed */
  574. disableDarkReaderSites: SiteSelectionOrNone;
  575. /** Whether to fix the styling of some elements from the SponsorBlock extension - does nothing if the extension is not installed */
  576. sponsorBlockIntegration: boolean;
  577. /** Whether to adjust styles so they look better when using the ThemeSong extension */
  578. themeSongIntegration: boolean;
  579. /** Lightness of the color used when ThemeSong is enabled */
  580. themeSongLightness: ColorLightnessPref;
  581. //#region plugins
  582. /** Button that opens the plugin list dialog */
  583. openPluginList: undefined;
  584. /** Amount of seconds until the feature initialization times out */
  585. initTimeout: number;
  586. //#region misc
  587. /** The locale to use for translations */
  588. locale: TrLocale;
  589. /** Whether to default to US-English if the translation for the set locale is missing */
  590. localeFallback: boolean;
  591. /** Whether to check for updates to the script */
  592. versionCheck: boolean;
  593. /** Button to check for updates */
  594. checkVersionNow: undefined;
  595. /** The console log level - 0 = Debug, 1 = Info */
  596. logLevel: LogLevel;
  597. /** Amount of seconds to show BYTM's toasts for */
  598. toastDuration: number;
  599. /** Whether to show a toast on generic errors */
  600. showToastOnGenericError: boolean;
  601. /** Button that resets the config to the default state */
  602. resetConfig: undefined;
  603. /** Button to reset every DataStore instance to their default values */
  604. resetEverything: undefined;
  605. /** Whether to show advanced settings in the config menu */
  606. advancedMode: boolean;
  607. }