From c25bd5780e2baa933cf7578e9b855fb767ee703c Mon Sep 17 00:00:00 2001 From: GooseOb Date: Mon, 13 May 2024 16:43:53 +0200 Subject: [PATCH] fix quality settings applying --- index.ts | 12 ++++++------ package.json | 2 +- types.ts | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/index.ts b/index.ts index 6e76d26..4328d30 100644 --- a/index.ts +++ b/index.ts @@ -261,13 +261,13 @@ const findInNodeList = ( }; const ytMenu: YtMenu = { - updatePlayer(plr: HTMLElement) { + async updatePlayer(plr: HTMLElement) { this.element = plr.querySelector('.ytp-settings-menu'); this._btn = plr.querySelector('.ytp-settings-button'); - restoreFocusAfter(() => { - this._btn.click(); - this._btn.click(); - }); + const clickBtn = this._btn.click.bind(this._btn); + restoreFocusAfter(clickBtn); + await delay(50); + restoreFocusAfter(clickBtn); }, element: null, _btn: null, @@ -392,7 +392,7 @@ const onPageChange = async () => { await delay(1_000); const getAd = () => plr.querySelector('.ytp-ad-player-overlay'); if (getAd()) await until(getAd, (ad) => !ad, 200_000); - ytMenu.updatePlayer(plr); + await ytMenu.updatePlayer(plr); const getMenuItems = () => ytMenu.element.querySelectorAll( '.ytp-menuitem[role="menuitem"]' diff --git a/package.json b/package.json index f486479..632f42e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "yt-defaulter", "author": "GooseOb", - "version": "1.9.3", + "version": "1.9.4", "repository": { "type": "git", "url": "git+https://github.com/GooseOb/YT-Defaulter.git" diff --git a/types.ts b/types.ts index bebc160..938b702 100644 --- a/types.ts +++ b/types.ts @@ -63,7 +63,7 @@ type YtSettingItem = HTMLDivElement & { role: 'menuitem' }; type YtMenu = { element: HTMLElement & ParentNode; _btn: HTMLElement; - updatePlayer(plr: HTMLElement): void; + updatePlayer(plr: HTMLElement): Promise; isOpen(): boolean; setOpen(bool: boolean): void; openItem(this: YtMenu, item: YtSettingItem): NodeListOf;