Start the project, get the canvas resolution. It's that easy.
This works completely different to the original. By slowly moving a sprite one pixel at a time until it reaches the edge (yes, this still works) and setting the variable to the relevant position, once for x and again for y. You know, the classic way. Except hiding it makes it run instantaneously. as I realised through a happy accident while playing around with getting an unrelated project to scale to any resolution. Want the original? Here ya go, I guess... https://scratch.mit.edu/projects/1237148519