fix netflix fix some more

This commit is contained in:
Tamius Han 2025-01-02 06:32:43 +01:00
parent 8d47eaf74c
commit 303213da73
2 changed files with 8 additions and 3 deletions

View File

@ -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;

View File

@ -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