diff --git a/src/ext/lib/video-transform/Resizer.ts b/src/ext/lib/video-transform/Resizer.ts index 7655b5e..7eee030 100644 --- a/src/ext/lib/video-transform/Resizer.ts +++ b/src/ext/lib/video-transform/Resizer.ts @@ -720,7 +720,7 @@ class Resizer { y: 0 }; - const problemStats = getElementStyles(this.video, ['top', 'left', 'transform']); + const problemStats = getElementStyles(this.video, ['top', 'left', 'transform'], ['transform']); if (problemStats.left?.css && problemStats.top?.css && problemStats.transform?.css?.includes(`translate(-${problemStats.left.css}, -${problemStats.top.css})`)) { translate.x -= ~~problemStats.left.pxValue; translate.y -= ~~problemStats.top.pxValue; diff --git a/src/ext/util/getElementStyles.ts b/src/ext/util/getElementStyles.ts index 3df7e4a..e60860e 100644 --- a/src/ext/util/getElementStyles.ts +++ b/src/ext/util/getElementStyles.ts @@ -49,7 +49,7 @@ function getPixelValue(value: string, element?: HTMLElement, prop?: string) { } }; -export default function getElementStyles(element: HTMLElement, props: string[]): ProcessedElementStyles { +export default function getElementStyles(element: HTMLElement, props: string[], theoryProps?: string[]): ProcessedElementStyles { const stylesheets = document.styleSheets; const computedStyles = getComputedStyle(element); const stylesOut = {}; @@ -68,12 +68,17 @@ export default function getElementStyles(element: HTMLElement, props: string[]): } const cssValue = rule.style.getPropertyValue(property); + + if (theoryProps?.includes(property)) { + stylesOut[property] = {css: cssValue}; + } + const actualValue = computedStyles.getPropertyValue(property); const theory = getPixelValue(cssValue, element, property); const practice = getPixelValue(actualValue, element, property); - if (theory === practice) { + if (theory && practice && (Math.abs(theory - practice) < 1)) { stylesOut[property] = { css: cssValue, pxValue: theory