Scriptlets icon indicating copy to clipboard operation
Scriptlets copied to clipboard

improve `spoof-css`

Open piquark6046 opened this issue 1 year ago • 1 comments

In jQuery, height() and width() methods use Element.prototype.getBoundingClientRect to calculate size of an element. However, AdGuard's spoof-css scriptlet does not mock completely the property.

Screenshot

image

piquark6046 avatar Oct 29 '24 05:10 piquark6046

As far as I understand, the problem occurs when 2 (or more) spoof-css scriptlets are used, for example:

example.org#%#//scriptlet('spoof-css', 'h1', 'width', '1000')
example.org#%#//scriptlet('spoof-css', 'h1', 'height', '2000')

and it looks like that the last one override/changes value set in previous scriptlet.

AdamWr avatar Oct 29 '24 07:10 AdamWr

exploader.net uses getBoundingClientRect to bypass css rule to set left: -4000px etc.

Code snippet
                    let bounds = ele.getBoundingClientRect();
                    if (bounds.left < 0 || (bounds.right > window.innerWidth && window.innerWidth > 1200) || bounds.top < 0) {
                        window.d7ad0a5447d73fcf18574784d7f74 = false;
                        window.abf730d17dd9b673c7ef9c01d711de1 = false;
                        return;
                    } 

uBO's fix that I confirmed working: https://github.com/gorhill/uBlock/commit/5f5e3d730f Should I open a new issue for this?

Yuki2718 avatar Dec 17 '24 10:12 Yuki2718

The changes related to https://github.com/AdguardTeam/Scriptlets/issues/498 should also fixes this issue.

AdamWr avatar May 23 '25 12:05 AdamWr