types.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. import { NanoEmitter, type 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 resources from "../assets/resources.json";
  6. import type locales from "../assets/locales.json";
  7. import type { getResourceUrl, getSessionId, getVideoTime, TrLocale, t, tp, fetchVideoVotes, onInteraction, getThumbnailUrl, getBestThumbnailUrl, getLocale, hasKey, hasKeyFor, getDomain, waitVideoElementReady, setInnerHtml, getCurrentMediaType } from "./utils/index.js";
  8. import type { SiteEventsMap } from "./siteEvents.js";
  9. import type { InterfaceEventsMap, getAutoLikeDataInterface, getFeaturesInterface, getPluginInfo, registerPlugin, saveAutoLikeDataInterface, saveFeaturesInterface, setLocaleInterface } from "./interface.js";
  10. import type { BytmDialog, ExImDialog, createCircularBtn, createHotkeyInput, createRipple, createToggleInput, showIconToast, showToast } from "./components/index.js";
  11. import type { fetchLyricsUrlTop, sanitizeArtists, sanitizeSong } from "./features/lyrics.js";
  12. import type { getLyricsCacheEntry } from "./features/lyricsCache.js";
  13. import type { showPrompt } from "./dialogs/prompt.js";
  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 NumberNotation = "short" | "long";
  94. export type ColorLightness = "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: typeof 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 has access to hidden config values */
  141. HiddenConfigValues = 1,
  142. /** Plugin can write to the feature configuration */
  143. WriteFeatureConfig = 2,
  144. /** Plugin can write to the lyrics cache */
  145. WriteLyricsCache = 4,
  146. /** Plugin can add new translations and overwrite existing ones */
  147. WriteTranslations = 8,
  148. /** Plugin can create modal dialogs */
  149. CreateModalDialogs = 16,
  150. /** Plugin can read and write auto-like data */
  151. ReadAndWriteAutoLikeData = 32,
  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 */
  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 =
  233. & {
  234. def: PluginDef;
  235. }
  236. & Pick<PluginRegisterResult, "events">;
  237. /** All functions exposed by the interface on the global `BYTM` object */
  238. export type InterfaceFunctions = {
  239. // meta:
  240. /** Registers a plugin with BYTM. Needed to receive the token for making authenticated function calls. */
  241. registerPlugin: typeof registerPlugin;
  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. // dom:
  258. /** Sets the innerHTML property of the provided element to a sanitized version of the provided HTML string */
  259. setInnerHtml: typeof setInnerHtml;
  260. /** Adds a listener to one of the already present SelectorObserver instances */
  261. addSelectorListener: typeof addSelectorListener;
  262. /** Registers accessible interaction listeners (click, enter, space) on the provided element */
  263. onInteraction: typeof onInteraction;
  264. /**
  265. * Returns the current video time (on both YT and YTM)
  266. * In case it can't be determined on YT, mouse movement is simulated to bring up the video time
  267. * 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
  268. */
  269. getVideoTime: typeof getVideoTime;
  270. /** Returns the thumbnail URL for the provided video ID and thumbnail quality */
  271. getThumbnailUrl: typeof getThumbnailUrl;
  272. /** Returns the thumbnail URL with the best quality for the provided video ID */
  273. getBestThumbnailUrl: typeof getBestThumbnailUrl;
  274. /** Resolves the returned promise when the video element is queryable in the DOM */
  275. waitVideoElementReady: typeof waitVideoElementReady;
  276. /** (On YTM only) returns the current media type (video or song) */
  277. getCurrentMediaType: typeof getCurrentMediaType;
  278. // translations:
  279. /** 🔒 Sets the locale for all new translations */
  280. setLocale: typeof setLocaleInterface;
  281. /** Returns the current locale */
  282. getLocale: typeof getLocale;
  283. /** Returns whether a translation key exists for the set locale */
  284. hasKey: typeof hasKey;
  285. /** Returns whether a translation key exists for the provided locale */
  286. hasKeyFor: typeof hasKeyFor;
  287. /** Returns the translation for the provided translation key and set locale (check the files in the folder `assets/translations`) */
  288. t: typeof t;
  289. /** Returns the translation for the provided translation key, including pluralization identifier and set locale (check the files in the folder `assets/translations`) */
  290. tp: typeof tp;
  291. // feature config:
  292. /** 🔒 Returns the current feature configuration */
  293. getFeatures: typeof getFeaturesInterface;
  294. /** 🔒 Overwrites the feature configuration with the provided one */
  295. saveFeatures: typeof saveFeaturesInterface;
  296. // lyrics:
  297. /** Sanitizes the provided artist string - this needs to be done before calling other lyrics related functions! */
  298. sanitizeArtists: typeof sanitizeArtists;
  299. /** Sanitizes the provided song title string - this needs to be done before calling other lyrics related functions! */
  300. sanitizeSong: typeof sanitizeSong;
  301. /** 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. */
  302. fetchLyricsUrlTop: typeof fetchLyricsUrlTop;
  303. /** Returns the lyrics cache entry for the provided song and artist, if there is one. Never sends a request on its own. */
  304. getLyricsCacheEntry: typeof getLyricsCacheEntry;
  305. // auto-like:
  306. /** 🔒 Returns the current auto-like data */
  307. getAutoLikeData: typeof getAutoLikeDataInterface;
  308. /** 🔒 Overwrites the auto-like data */
  309. saveAutoLikeData: typeof saveAutoLikeDataInterface;
  310. /** Returns the votes for the provided video ID from the ReturnYoutubeDislike API */
  311. fetchVideoVotes: typeof fetchVideoVotes;
  312. // components:
  313. /** Creates a new hotkey input component */
  314. createHotkeyInput: typeof createHotkeyInput;
  315. /** Creates a new toggle input component */
  316. createToggleInput: typeof createToggleInput;
  317. /** Creates a new circular button component */
  318. createCircularBtn: typeof createCircularBtn;
  319. /** Creates a new ripple effect on the provided element or creates an empty element that has the effect */
  320. createRipple: typeof createRipple;
  321. /** Shows a toast with the provided text */
  322. showToast: typeof showToast;
  323. /** Shows a toast with the provided text and an icon */
  324. showIconToast: typeof showIconToast;
  325. /** Shows a styled confirm() or alert() dialog with the provided message */
  326. showPrompt: typeof showPrompt;
  327. };
  328. //#region feature defs
  329. export type FeatureKey = keyof FeatureConfig;
  330. export type FeatureCategory =
  331. | "layout"
  332. | "volume"
  333. | "songLists"
  334. | "behavior"
  335. | "input"
  336. | "lyrics"
  337. | "integrations"
  338. | "general";
  339. type SelectOption = {
  340. value: string | number;
  341. label: string;
  342. };
  343. type FeatureTypeProps = ({
  344. type: "toggle";
  345. default: boolean;
  346. } & FeatureFuncProps)
  347. | ({
  348. type: "number";
  349. default: number;
  350. min: number;
  351. max?: number;
  352. step?: number;
  353. unit?: string | ((val: number) => string);
  354. } & FeatureFuncProps)
  355. | ({
  356. type: "select";
  357. default: string | number;
  358. options: SelectOption[] | (() => SelectOption[]);
  359. } & FeatureFuncProps)
  360. | ({
  361. type: "slider";
  362. default: number;
  363. min: number;
  364. max: number;
  365. step?: number;
  366. unit?: string | ((val: number) => string);
  367. } & FeatureFuncProps)
  368. | ({
  369. type: "hotkey";
  370. default: HotkeyObj;
  371. } & FeatureFuncProps)
  372. | ({
  373. type: "text";
  374. default: string;
  375. normalize?: (val: string) => string;
  376. } & FeatureFuncProps)
  377. | {
  378. type: "button";
  379. default?: undefined;
  380. click: () => Promise<void | unknown> | void | unknown;
  381. }
  382. type FeatureFuncProps = (
  383. {
  384. /** Whether the feature requires a page reload to take effect */
  385. reloadRequired: false;
  386. /** Called to instantiate the feature on the page */
  387. enable: (featCfg: FeatureConfig) => void,
  388. }
  389. | {
  390. /** Whether the feature requires a page reload to take effect */
  391. reloadRequired?: true;
  392. /** Called to instantiate the feature on the page */
  393. enable?: undefined;
  394. }
  395. ) & (
  396. {
  397. /** Called to remove all traces of the feature from the page and memory (includes event listeners) */
  398. disable?: (feats: FeatureConfig) => void,
  399. }
  400. | {
  401. /** Called to update the feature's behavior when the config changes */
  402. change?: (key: FeatureKey, initialVal: number | boolean | Record<string, unknown>, newVal: number | boolean | Record<string, unknown>) => void,
  403. }
  404. );
  405. /**
  406. * The feature info object that contains all properties necessary to construct the config menu and the feature config object.
  407. * All values are loosely typed so try to only use this with the `satisfies` keyword.
  408. * Use `typeof featInfo` (from `src/features/index.ts`) instead for full type safety.
  409. */
  410. export type FeatureInfo = Record<
  411. keyof FeatureConfig,
  412. {
  413. category: FeatureCategory;
  414. /**
  415. * HTML string that will be the help text for this feature
  416. * Specifying a function is useful for pluralizing or inserting values into the translation at runtime
  417. */
  418. helpText?: string | (() => string);
  419. /** Whether the value should be hidden in the config menu and from plugins */
  420. valueHidden?: boolean;
  421. /** Transformation function called before the value is rendered in the config menu */
  422. renderValue?: (value: string) => string | Promise<string>;
  423. /** HTML string that is appended to the end of a feature's text description */
  424. textAdornment?: () => (Promise<string | undefined> | string | undefined);
  425. /** Whether to only show this feature when advanced mode is activated (default false) */
  426. advanced?: boolean;
  427. }
  428. & FeatureTypeProps
  429. >;
  430. //#region feature config
  431. /** Feature configuration */
  432. export interface FeatureConfig {
  433. //#region layout
  434. /** Show a BetterYTM watermark under the YTM logo */
  435. watermarkEnabled: boolean;
  436. /** Remove the "si" tracking parameter from links in the share menu? */
  437. removeShareTrackingParam: boolean;
  438. /** On which sites to remove the "si" tracking parameter from links in the share menu */
  439. removeShareTrackingParamSites: SiteSelection;
  440. /** Enable skipping to a specific time in the video by pressing a number key (0-9) */
  441. numKeysSkipToTime: boolean;
  442. /** Fix spacing issues in the layout */
  443. fixSpacing: boolean;
  444. /** Where to show a thumbnail overlay over the video element and whether to show it at all */
  445. thumbnailOverlayBehavior: "never" | "videosOnly" | "songsOnly" | "always";
  446. /** Whether to show a button to toggle the thumbnail overlay in the media controls */
  447. thumbnailOverlayToggleBtnShown: boolean;
  448. /** Whether to show an indicator on the thumbnail overlay when it is active */
  449. thumbnailOverlayShowIndicator: boolean;
  450. /** The opacity of the thumbnail overlay indicator element */
  451. thumbnailOverlayIndicatorOpacity: number;
  452. /** How to fit the thumbnail overlay image */
  453. thumbnailOverlayImageFit: "cover" | "contain" | "fill";
  454. /** Hide the cursor when it's idling on the video element for a while */
  455. hideCursorOnIdle: boolean;
  456. /** Delay in seconds after which the cursor should be hidden */
  457. hideCursorOnIdleDelay: number;
  458. /** Whether to fix various issues in the layout when HDR is supported and active */
  459. fixHdrIssues: boolean;
  460. /** Whether to show the like/dislike ratio on the currently playing song */
  461. showVotes: boolean;
  462. /** Which format to use for the like/dislike ratio on the currently playing song */
  463. showVotesFormat: NumberNotation;
  464. //#region volume
  465. /** Add a percentage label to the volume slider */
  466. volumeSliderLabel: boolean;
  467. /** The width of the volume slider in pixels */
  468. volumeSliderSize: number;
  469. /** Volume slider sensitivity - the smaller this number, the finer the volume control */
  470. volumeSliderStep: number;
  471. /** Volume slider scroll wheel sensitivity */
  472. volumeSliderScrollStep: number;
  473. /** Whether the volume should be locked to the same level across all tabs (changing in one changes in all others too) */
  474. volumeSharedBetweenTabs: boolean;
  475. /** Whether to set an initial volume level for each new session */
  476. setInitialTabVolume: boolean;
  477. /** The initial volume level to set for each new session */
  478. initialTabVolumeLevel: number;
  479. //#region song lists
  480. /** Add a button to each song in the queue to quickly open its lyrics page */
  481. lyricsQueueButton: boolean;
  482. /** Add a button to each song in the queue to quickly remove it */
  483. deleteFromQueueButton: boolean;
  484. /** Where to place the buttons in the queue */
  485. listButtonsPlacement: "queueOnly" | "everywhere";
  486. /** Add a button above the queue to scroll to the currently playing song */
  487. scrollToActiveSongBtn: boolean;
  488. /** Add a button above the queue to clear it */
  489. clearQueueBtn: boolean;
  490. //#region behavior
  491. /** Whether to completely disable the popup that sometimes appears before leaving the site */
  492. disableBeforeUnloadPopup: boolean;
  493. /** After how many milliseconds to close permanent toasts */
  494. closeToastsTimeout: number;
  495. /** Remember the last song's time when reloading or restoring the tab */
  496. rememberSongTime: boolean;
  497. /** Where to remember the song time */
  498. rememberSongTimeSites: SiteSelection;
  499. /** Time in seconds to remember the song time for */
  500. rememberSongTimeDuration: number;
  501. /** Time in seconds to subtract from the remembered song time */
  502. rememberSongTimeReduction: number;
  503. /** Minimum time in seconds the song needs to be played before it is remembered */
  504. rememberSongTimeMinPlayTime: number;
  505. //#region input
  506. /** Arrow keys skip forwards and backwards */
  507. arrowKeySupport: boolean;
  508. /** By how many seconds to skip when pressing the arrow keys */
  509. arrowKeySkipBy: number;
  510. /** Add a hotkey to switch between the YT and YTM sites on a video / song */
  511. switchBetweenSites: boolean;
  512. /** The hotkey that needs to be pressed to initiate the site switch */
  513. switchSitesHotkey: HotkeyObj;
  514. /** Make it so middle clicking a song to open it in a new tab (through thumbnail and song title) is easier */
  515. anchorImprovements: boolean;
  516. /** Whether to auto-like all played videos of configured channels */
  517. autoLikeChannels: boolean;
  518. /** Whether to show toggle buttons on the channel page to enable/disable auto-liking for that channel */
  519. autoLikeChannelToggleBtn: boolean;
  520. // TODO(v2.2):
  521. // /** Whether to show a toggle button in the media controls to enable/disable auto-liking for those channel(s) */
  522. // autoLikePlayerBarToggleBtn: boolean;
  523. /** How long to wait after a video has started playing to auto-like it */
  524. autoLikeTimeout: number;
  525. /** Whether to show a toast when a video is auto-liked */
  526. autoLikeShowToast: boolean;
  527. /** Opens the auto-like channels management dialog */
  528. autoLikeOpenMgmtDialog: undefined;
  529. //#region lyrics
  530. /** Add a button to the media controls to open the current song's lyrics on genius.com in a new tab */
  531. geniusLyrics: boolean;
  532. /** Base URL to use for GeniURL */
  533. geniUrlBase: string;
  534. /** Token to use for GeniURL */
  535. geniUrlToken: string;
  536. /** Max size of lyrics cache */
  537. lyricsCacheMaxSize: number;
  538. /** Max TTL of lyrics cache entries, in ms */
  539. lyricsCacheTTL: number;
  540. /** Button to clear lyrics cache */
  541. clearLyricsCache: undefined;
  542. // /** Whether to use advanced filtering when searching for lyrics (exact, exact-ish) */
  543. // advancedLyricsFilter: boolean;
  544. //#region integrations
  545. /** On which sites to disable Dark Reader - does nothing if the extension is not installed */
  546. disableDarkReaderSites: SiteSelectionOrNone;
  547. /** Whether to fix the styling of some elements from the SponsorBlock extension - does nothing if the extension is not installed */
  548. sponsorBlockIntegration: boolean;
  549. /** Whether to adjust styles so they look better when using the ThemeSong extension */
  550. themeSongIntegration: boolean;
  551. /** Lightness of the color used when ThemeSong is enabled */
  552. themeSongLightness: ColorLightness;
  553. //#region misc
  554. /** The locale to use for translations */
  555. locale: TrLocale;
  556. /** Whether to default to US-English if the translation for the set locale is missing */
  557. localeFallback: boolean;
  558. /** Whether to check for updates to the script */
  559. versionCheck: boolean;
  560. /** Button to check for updates */
  561. checkVersionNow: undefined;
  562. /** The console log level - 0 = Debug, 1 = Info */
  563. logLevel: LogLevel;
  564. /** Amount of seconds until the feature initialization times out */
  565. initTimeout: number;
  566. /** Amount of seconds to show BYTM's toasts for */
  567. toastDuration: number;
  568. /** Whether to show a toast on generic errors */
  569. showToastOnGenericError: boolean;
  570. /** Button that resets the config to the default state */
  571. resetConfig: undefined;
  572. /** Whether to show advanced settings in the config menu */
  573. advancedMode: boolean;
  574. }