types.ts 24 KB

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