mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 12:42:06 +00:00
feat(exponential-volume): fix type of WeakMap
Co-authored-by: Su-Yong <simssy2205@gmail.com>
This commit is contained in:
@ -7,14 +7,13 @@ const exponentialVolume = () => {
|
|||||||
// 0.05 (or 5%) is the lowest you can select in the UI which with an exponent of 3 becomes 0.000125 or 0.0125%
|
// 0.05 (or 5%) is the lowest you can select in the UI which with an exponent of 3 becomes 0.000125 or 0.0125%
|
||||||
const EXPONENT = 3;
|
const EXPONENT = 3;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
const storedOriginalVolumes = new WeakMap<HTMLMediaElement, number>();
|
||||||
const storedOriginalVolumes = new WeakMap<any, number>();
|
|
||||||
const propertyDescriptor = Object.getOwnPropertyDescriptor(
|
const propertyDescriptor = Object.getOwnPropertyDescriptor(
|
||||||
HTMLMediaElement.prototype,
|
HTMLMediaElement.prototype,
|
||||||
'volume',
|
'volume',
|
||||||
);
|
);
|
||||||
Object.defineProperty(HTMLMediaElement.prototype, 'volume', {
|
Object.defineProperty(HTMLMediaElement.prototype, 'volume', {
|
||||||
get() {
|
get(this: HTMLMediaElement) {
|
||||||
const lowVolume = propertyDescriptor?.get?.call(this) as number ?? 0;
|
const lowVolume = propertyDescriptor?.get?.call(this) as number ?? 0;
|
||||||
const calculatedOriginalVolume = lowVolume ** (1 / EXPONENT);
|
const calculatedOriginalVolume = lowVolume ** (1 / EXPONENT);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user