Skip to content

Commit 061494f

Browse files
committed
[#82] Fix player component selectors
1 parent 6351ca4 commit 061494f

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/scripts/page/components.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,16 @@ export const minMaxPos = (settings: Partial<Settings>, includeDisabled = false)
5656
export const slot = <S, T>(name: Comp, comp: PlayerComponentSetting, left: S, right: T): S | T => (comp?.position ?? defaultPositions[name]) < 0 ? right : left;
5757
export const setDefaultIds = () => {
5858
const left = document.querySelectorAll('#video-controls > :last-child > :first-child > *');
59-
const right = document.querySelectorAll('#video-controls > :last-child > :last-child > *:not(div:empty)');
59+
const right = document.querySelectorAll('#video-controls > :last-child > :nth-child(2) > *');
60+
console.dev.debug('Player elements left', left, 'right', right);
6061
if (left.length != 3)
61-
throw new Error('Expected three buttons on left');
62+
throw new Error(`Expected three buttons on left, got ${left.length}`);
6263
const hasChromecast = document.querySelector('#video-controls > div > :last-child > [aria-label="Chromecast"]');
6364
if (hasChromecast) {
6465
if (right.length != 6 && right.length != 7)
65-
throw new Error('Chromecast detected, expected 6 or 7 buttons on right');
66+
throw new Error(`Chromecast detected, expected 6 or 7 buttons on right, got ${right.length}`);
6667
} else if (right.length != 4 && right.length != 5)
67-
throw new Error('No Chromecast detected, expected 4 or 5 buttons on right');
68+
throw new Error(`No Chromecast detected, expected 4 or 5 buttons on right, got ${right.length}`);
6869
const expectNoSubtitle = hasChromecast ? right.length === 6 : right.length === 4;
6970
const givenLeft = builtin.slice(0, left.length);
7071
const givenRight = builtin.slice(left.length)

src/scripts/page/player.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ const addPlayerControls = async (player: Player) => {
165165
await waitForSubtitles(player);
166166
} catch { }
167167

168-
const controls = player.parentElement.querySelectorAll('.icon-spacing');
168+
169+
const controls = document.querySelectorAll('#video-controls > :last-child > :first-child, #video-controls > :last-child > :nth-child(2)');
169170
const left = controls[0];
170171
const right = controls[controls.length - 1];
171172
const collect = (id: string) => {

0 commit comments

Comments
 (0)