From 296f146835257575ca1a2fab6921f56d6337da27 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Thu, 9 Jun 2022 01:28:46 +0200 Subject: [PATCH] Refactor player detection + have player detection log some data for use in settings window --- src/ext/lib/video-data/PlayerData.ts | 327 +++++++++++++++------------ 1 file changed, 177 insertions(+), 150 deletions(-) diff --git a/src/ext/lib/video-data/PlayerData.ts b/src/ext/lib/video-data/PlayerData.ts index fabb10f..aa95c32 100644 --- a/src/ext/lib/video-data/PlayerData.ts +++ b/src/ext/lib/video-data/PlayerData.ts @@ -65,6 +65,8 @@ class PlayerData { private observer: ResizeObserver; private ui: any; + + elementStack: any[] = []; //#endregion /** @@ -140,7 +142,6 @@ class PlayerData { return ( ihdiff < 5 && iwdiff < 5 ); } - /** * */ @@ -414,162 +415,188 @@ class PlayerData { } //#endregion - getPlayer() { + /** + * Finds and returns HTML element of the player + */ + getPlayer(options?: {verbose?: boolean}) { const host = window.location.hostname; let element = this.video.parentNode; const videoWidth = this.video.offsetWidth; const videoHeight = this.video.offsetHeight; - const elementQ = []; - const scorePenalty = 10; - const sizePenaltyMultiplier = 0.1; - let penaltyMultiplier = 0; - let score; + let playerCandidate; - try { - if(! element ){ - this.logger.log('info', 'debug', "[PlayerDetect::_pd_getPlayer] element is not valid, doing nothing.", element) - if(this.element) { - const ths = this; - } - this.element = undefined; - this.dimensions = undefined; - return; - } + const elementStack: any[] = [{ + element: this.video, + type: 'video' + }]; - // log the entire hierarchy from