types.ts 26 KB

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