types.ts 27 KB

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