types.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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 } 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" | "compressionFormat">
  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. /** All functions exposed by the interface on the global `BYTM` object */
  242. export type InterfaceFunctions = {
  243. // meta:
  244. /** 🔒 Checks if the plugin with the given name and namespace is registered and returns an info object about it */
  245. getPluginInfo: typeof getPluginInfo;
  246. // bytm-specific:
  247. /** Returns the current domain as a constant string representation */
  248. getDomain: typeof getDomain;
  249. /**
  250. * Returns the URL of a resource as defined in `assets/resources.json`
  251. * There are also some resources like translation files that get added by `tools/post-build.ts`
  252. *
  253. * The returned URL is a `blob:` URL served up by the userscript extension
  254. * This makes the resource fast to fetch and also prevents CORS issues
  255. */
  256. getResourceUrl: typeof getResourceUrl;
  257. /** Returns the unique session ID for the current tab */
  258. getSessionId: typeof getSessionId;
  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. /** (On YTM only) returns the current media type (video or song) */
  279. getCurrentMediaType: typeof getCurrentMediaType;
  280. // translations:
  281. /** 🔒 Sets the locale for all new translations */
  282. setLocale: typeof setLocaleInterface;
  283. /** Returns the current locale */
  284. getLocale: typeof getLocale;
  285. /** Returns whether a translation key exists for the set locale */
  286. hasKey: typeof hasKey;
  287. /** Returns whether a translation key exists for the provided locale */
  288. hasKeyFor: typeof hasKeyFor;
  289. /** Returns the translation for the provided translation key and currently set locale (check the files in the folder `assets/translations`) */
  290. t: typeof t;
  291. /** Returns the translation for the provided translation key, including pluralization identifier and set locale (check the files in the folder `assets/translations`) */
  292. tp: typeof tp;
  293. /** Returns the translation for the provided translation key and provided locale (check the files in the folder `assets/translations`) */
  294. tl: typeof tl;
  295. /** Returns the translation for the provided translation key, including pluralization identifier and provided locale (check the files in the folder `assets/translations`) */
  296. tlp: typeof tlp;
  297. // feature config:
  298. /** 🔒 Returns the current feature configuration */
  299. getFeatures: typeof getFeaturesInterface;
  300. /** 🔒 Overwrites the feature configuration with the provided one */
  301. saveFeatures: typeof saveFeaturesInterface;
  302. // lyrics:
  303. /** Sanitizes the provided artist string - this needs to be done before calling other lyrics related functions! */
  304. sanitizeArtists: typeof sanitizeArtists;
  305. /** Sanitizes the provided song title string - this needs to be done before calling other lyrics related functions! */
  306. sanitizeSong: typeof sanitizeSong;
  307. /** 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. */
  308. fetchLyricsUrlTop: typeof fetchLyricsUrlTop;
  309. /** Returns the lyrics cache entry for the provided song and artist, if there is one. Never sends a request on its own. */
  310. getLyricsCacheEntry: typeof getLyricsCacheEntry;
  311. // auto-like:
  312. /** 🔒 Returns the current auto-like data */
  313. getAutoLikeData: typeof getAutoLikeDataInterface;
  314. /** 🔒 Overwrites the auto-like data */
  315. saveAutoLikeData: typeof saveAutoLikeDataInterface;
  316. /** Returns the votes for the provided video ID from the ReturnYoutubeDislike API */
  317. fetchVideoVotes: typeof fetchVideoVotes;
  318. // components:
  319. /** Creates a new hotkey input component */
  320. createHotkeyInput: typeof createHotkeyInput;
  321. /** Creates a new toggle input component */
  322. createToggleInput: typeof createToggleInput;
  323. /** Creates a new circular button component */
  324. createCircularBtn: typeof createCircularBtn;
  325. /** Creates a new ripple effect on the provided element or creates an empty element that has the effect */
  326. createRipple: typeof createRipple;
  327. /** Shows a toast with the provided text */
  328. showToast: typeof showToast;
  329. /** Shows a toast with the provided text and an icon */
  330. showIconToast: typeof showIconToast;
  331. /** Shows a styled confirm() or alert() dialog with the provided message */
  332. showPrompt: typeof showPrompt;
  333. // other:
  334. /** Formats a number to a string using the configured locale and configured or passed number notation */
  335. formatNumber: typeof formatNumber;
  336. };
  337. //#region feature defs
  338. /** Feature identifier */
  339. export type FeatureKey = keyof FeatureConfig;
  340. /** Feature category identifier */
  341. export type FeatureCategory =
  342. | "layout"
  343. | "volume"
  344. | "songLists"
  345. | "behavior"
  346. | "input"
  347. | "lyrics"
  348. | "integrations"
  349. | "plugins"
  350. | "general";
  351. type SelectOption = {
  352. value: string | number;
  353. label: string;
  354. };
  355. type FeatureTypeProps = ({
  356. type: "toggle";
  357. default: boolean;
  358. } & FeatureFuncProps)
  359. | ({
  360. type: "number";
  361. default: number;
  362. min: number;
  363. max?: number;
  364. step?: number;
  365. unit?: string | ((val: number) => string);
  366. } & FeatureFuncProps)
  367. | ({
  368. type: "select";
  369. default: string | number;
  370. options: SelectOption[] | (() => SelectOption[]);
  371. } & FeatureFuncProps)
  372. | ({
  373. type: "slider";
  374. default: number;
  375. min: number;
  376. max: number;
  377. step?: number;
  378. unit?: string | ((val: number) => string);
  379. } & FeatureFuncProps)
  380. | ({
  381. type: "hotkey";
  382. default: HotkeyObj;
  383. } & FeatureFuncProps)
  384. | ({
  385. type: "text";
  386. default: string;
  387. normalize?: (val: string) => string;
  388. } & FeatureFuncProps)
  389. | {
  390. type: "button";
  391. default?: undefined;
  392. click: () => Promise<void | unknown> | void | unknown;
  393. }
  394. type FeatureFuncProps = (
  395. {
  396. /** Whether the feature requires a page reload to take effect */
  397. reloadRequired: false;
  398. /** Called to instantiate the feature on the page */
  399. enable: (featCfg: FeatureConfig) => void,
  400. }
  401. | {
  402. /** Whether the feature requires a page reload to take effect */
  403. reloadRequired?: true;
  404. /** Called to instantiate the feature on the page */
  405. enable?: undefined;
  406. }
  407. ) & (
  408. {
  409. /** Called to remove all traces of the feature from the page and memory (includes event listeners) */
  410. disable?: (feats: FeatureConfig) => void,
  411. }
  412. | {
  413. /** Called to update the feature's behavior when the config changes */
  414. change?: (key: FeatureKey, initialVal: number | boolean | Record<string, unknown>, newVal: number | boolean | Record<string, unknown>) => void,
  415. }
  416. );
  417. /**
  418. * The feature info object that contains all properties necessary to construct the config menu and the feature config object.
  419. * All values are loosely typed so try to only use this via `const myObj = {} satisfies FeatureInfo;`
  420. * For full type safety, use `typeof featInfo` (from `src/features/index.ts`) instead.
  421. */
  422. export type FeatureInfo = Record<
  423. keyof FeatureConfig,
  424. {
  425. category: FeatureCategory;
  426. /**
  427. * HTML string that will be the help text for this feature
  428. * Specifying a function is useful for pluralizing or inserting values into the translation at runtime
  429. */
  430. helpText?: string | (() => string);
  431. /** Whether the value should be hidden in the config menu and from plugins */
  432. valueHidden?: boolean;
  433. /** Transformation function called before the value is rendered in the config menu */
  434. renderValue?: (value: string) => string | Promise<string>;
  435. /** HTML string that is appended to the end of a feature's text description */
  436. textAdornment?: () => (Promise<string | undefined> | string | undefined);
  437. /** Whether to only show this feature when advanced mode is activated (default false) */
  438. advanced?: boolean;
  439. }
  440. & FeatureTypeProps
  441. >;
  442. //#region feature config
  443. /** Feature configuration object, as saved in memory and persistent storage */
  444. export interface FeatureConfig {
  445. //#region layout
  446. /** Show a BetterYTM watermark under the YTM logo */
  447. watermarkEnabled: boolean;
  448. /** Remove the "si" tracking parameter from links in the share menu? */
  449. removeShareTrackingParam: boolean;
  450. /** On which sites to remove the "si" tracking parameter from links in the share menu */
  451. removeShareTrackingParamSites: SiteSelection;
  452. /** Enable skipping to a specific time in the video by pressing a number key (0-9) */
  453. numKeysSkipToTime: boolean;
  454. /** Fix spacing issues in the layout */
  455. fixSpacing: boolean;
  456. /** Where to show a thumbnail overlay over the video element and whether to show it at all */
  457. thumbnailOverlayBehavior: "never" | "videosOnly" | "songsOnly" | "always";
  458. /** Whether to show a button to toggle the thumbnail overlay in the media controls */
  459. thumbnailOverlayToggleBtnShown: boolean;
  460. /** Whether to show an indicator on the thumbnail overlay when it is active */
  461. thumbnailOverlayShowIndicator: boolean;
  462. /** The opacity of the thumbnail overlay indicator element */
  463. thumbnailOverlayIndicatorOpacity: number;
  464. /** How to fit the thumbnail overlay image */
  465. thumbnailOverlayImageFit: "cover" | "contain" | "fill";
  466. /** Hide the cursor when it's idling on the video element for a while */
  467. hideCursorOnIdle: boolean;
  468. /** Delay in seconds after which the cursor should be hidden */
  469. hideCursorOnIdleDelay: number;
  470. /** Whether to fix various issues in the layout when HDR is supported and active */
  471. fixHdrIssues: boolean;
  472. /** Whether to show the like/dislike ratio on the currently playing song */
  473. showVotes: boolean;
  474. /** Which format to use for the like/dislike ratio on the currently playing song */
  475. numbersFormat: NumberLengthFormat;
  476. //#region volume
  477. /** Add a percentage label to the volume slider */
  478. volumeSliderLabel: boolean;
  479. /** The width of the volume slider in pixels */
  480. volumeSliderSize: number;
  481. /** Volume slider sensitivity - the smaller this number, the finer the volume control */
  482. volumeSliderStep: number;
  483. /** Volume slider scroll wheel sensitivity */
  484. volumeSliderScrollStep: number;
  485. /** Whether the volume should be locked to the same level across all tabs (changing in one changes in all others too) */
  486. volumeSharedBetweenTabs: boolean;
  487. /** Whether to set an initial volume level for each new session */
  488. setInitialTabVolume: boolean;
  489. /** The initial volume level to set for each new session */
  490. initialTabVolumeLevel: number;
  491. //#region song lists
  492. /** Add a button to each song in the queue to quickly open its lyrics page */
  493. lyricsQueueButton: boolean;
  494. /** Add a button to each song in the queue to quickly remove it */
  495. deleteFromQueueButton: boolean;
  496. /** Where to place the buttons in the queue */
  497. listButtonsPlacement: "queueOnly" | "everywhere";
  498. /** Add a button above the queue to scroll to the currently playing song */
  499. scrollToActiveSongBtn: boolean;
  500. /** Add a button above the queue to clear it */
  501. clearQueueBtn: boolean;
  502. //#region behavior
  503. /** Whether to completely disable the popup that sometimes appears before leaving the site */
  504. disableBeforeUnloadPopup: boolean;
  505. /** After how many milliseconds to close permanent toasts */
  506. closeToastsTimeout: number;
  507. /** Remember the last song's time when reloading or restoring the tab */
  508. rememberSongTime: boolean;
  509. /** Where to remember the song time */
  510. rememberSongTimeSites: SiteSelection;
  511. /** Time in seconds to remember the song time for */
  512. rememberSongTimeDuration: number;
  513. /** Time in seconds to subtract from the remembered song time */
  514. rememberSongTimeReduction: number;
  515. /** Minimum time in seconds the song needs to be played before it is remembered */
  516. rememberSongTimeMinPlayTime: number;
  517. //#region input
  518. /** Arrow keys skip forwards and backwards */
  519. arrowKeySupport: boolean;
  520. /** By how many seconds to skip when pressing the arrow keys */
  521. arrowKeySkipBy: number;
  522. /** Add a hotkey to switch between the YT and YTM sites on a video / song */
  523. switchBetweenSites: boolean;
  524. /** The hotkey that needs to be pressed to initiate the site switch */
  525. switchSitesHotkey: HotkeyObj;
  526. /** Make it so middle clicking a song to open it in a new tab (through thumbnail and song title) is easier */
  527. anchorImprovements: boolean;
  528. /** Whether to auto-like all played videos of configured channels */
  529. autoLikeChannels: boolean;
  530. /** Whether to show toggle buttons on the channel page to enable/disable auto-liking for that channel */
  531. autoLikeChannelToggleBtn: boolean;
  532. // TODO(v2.2):
  533. // /** Whether to show a toggle button in the media controls to enable/disable auto-liking for those channel(s) */
  534. // autoLikePlayerBarToggleBtn: boolean;
  535. /** How long to wait after a video has started playing to auto-like it */
  536. autoLikeTimeout: number;
  537. /** Whether to show a toast when a video is auto-liked */
  538. autoLikeShowToast: boolean;
  539. /** Opens the auto-like channels management dialog */
  540. autoLikeOpenMgmtDialog: undefined;
  541. //#region lyrics
  542. /** Add a button to the media controls to open the current song's lyrics on genius.com in a new tab */
  543. geniusLyrics: boolean;
  544. /** Whether to show an error when no lyrics were found */
  545. errorOnLyricsNotFound: boolean;
  546. /** Base URL to use for GeniURL */
  547. geniUrlBase: string;
  548. /** Token to use for GeniURL */
  549. geniUrlToken: string;
  550. /** Max size of lyrics cache */
  551. lyricsCacheMaxSize: number;
  552. /** Max TTL of lyrics cache entries, in ms */
  553. lyricsCacheTTL: number;
  554. /** Button to clear lyrics cache */
  555. clearLyricsCache: undefined;
  556. // /** Whether to use advanced filtering when searching for lyrics (exact, exact-ish) */
  557. // advancedLyricsFilter: boolean;
  558. //#region integrations
  559. /** On which sites to disable Dark Reader - does nothing if the extension is not installed */
  560. disableDarkReaderSites: SiteSelectionOrNone;
  561. /** Whether to fix the styling of some elements from the SponsorBlock extension - does nothing if the extension is not installed */
  562. sponsorBlockIntegration: boolean;
  563. /** Whether to adjust styles so they look better when using the ThemeSong extension */
  564. themeSongIntegration: boolean;
  565. /** Lightness of the color used when ThemeSong is enabled */
  566. themeSongLightness: ColorLightnessPref;
  567. //#region plugins
  568. /** Button that opens the plugin list dialog */
  569. openPluginList: undefined;
  570. /** Amount of seconds until the feature initialization times out */
  571. initTimeout: number;
  572. //#region misc
  573. /** The locale to use for translations */
  574. locale: TrLocale;
  575. /** Whether to default to US-English if the translation for the set locale is missing */
  576. localeFallback: boolean;
  577. /** Whether to check for updates to the script */
  578. versionCheck: boolean;
  579. /** Button to check for updates */
  580. checkVersionNow: undefined;
  581. /** The console log level - 0 = Debug, 1 = Info */
  582. logLevel: LogLevel;
  583. /** Amount of seconds to show BYTM's toasts for */
  584. toastDuration: number;
  585. /** Whether to show a toast on generic errors */
  586. showToastOnGenericError: boolean;
  587. /** Button that resets the config to the default state */
  588. resetConfig: undefined;
  589. /** Button to reset every DataStore instance to their default values */
  590. resetEverything: undefined;
  591. /** Whether to show advanced settings in the config menu */
  592. advancedMode: boolean;
  593. }