Chrome window.screenX set to zero at the wrong place

function f(){
    window.requestAnimationFrame(
        ()=>{
            document.body.innerHTML = "X: "+window.screenX+"<br>Y: "+window.screenY;
            f();
        }
    );
};
f();

enter image description here

As you can see in the image, the X coordinate is set to zero at the wrong place, since the webbrowser is not stick to the left side of the screen. In fact, when the webbrowser is stick to the left, the X coordinate is negative:

enter image description here

My question is: How can I get the correct coordinates in spite of this in a reliable way? Is it ok to check if the webbrowser is Chrome and hardcode an offset to make sure the X coordinate is correct? Isn't there a better way? Am I getting the X coordinate the wrong way?