types.ts 26 KB

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