diff --git a/src/ext/lib/video-data/PlayerData.js b/src/ext/lib/video-data/PlayerData.js index 168ce55..9cea97a 100644 --- a/src/ext/lib/video-data/PlayerData.js +++ b/src/ext/lib/video-data/PlayerData.js @@ -215,7 +215,8 @@ class PlayerData { getPlayer() { const host = window.location.host; let element = this.video.parentNode; - const videoWidth = this.video.offsetWidth, videoHeight = this.video.offsetHeight; + const videoWidth = this.video.offsetWidth; + const videoHeight = this.video.offsetHeight; const elementQ = []; let scorePenalty = 0; let score; @@ -352,6 +353,20 @@ class PlayerData { return a > b - tolerance && a < b + tolerance; } + forceDetectPlayerElementChange() { + // save current dimensions before refreshing the player object + const oldDimensions = this.dimensions; + this.getPlayer(); + + // compare new player object dimensions with the old dimensions + // don't fucking trigger changes if nothing changed + if (this.dimensions.width === this.dimensions.width && this.dimensions.height === this.dimensions.height) { + return false; + } else { + return true; + } + } + forceRefreshPlayerElement() { this.getPlayer(); } diff --git a/src/ext/lib/video-data/VideoData.js b/src/ext/lib/video-data/VideoData.js index 11eb481..be62eab 100644 --- a/src/ext/lib/video-data/VideoData.js +++ b/src/ext/lib/video-data/VideoData.js @@ -154,8 +154,12 @@ class VideoData { && this.isWithin(vh, (ph - (translateY * 2)), 2) && this.isWithin(vw, (pw - (translateX * 2)), 2)) { } else { - this.player.forceRefreshPlayerElement(); - this.restoreAr(); + if (this.player.forceDetectPlayerElementChange()) { + this.logger.log('info', 'debug', "Video dimensions changed. Triggering restoreAr()"); + this.restoreAr(); + } else { + this.logger.log('info', 'playerRescan', "Video dimensions didn't change."); + } } } catch(e) {