Absolutely, it can! The script would just have to be changed to use something like this:
const width = window.screen.width * window.devicePixelRatio; const height = window.screen.height * window.devicePixelRatio;
or, if you only want the actual size of the game's window (for windowed mode), and not the total screen size:
const width = window.screen.availWidth * window.devicePixelRatio; const height = window.screen.availHeight * window.devicePixelRatio;
The problem with this (and the reason why I didn't add it to the script) is that pictures will not scale! The game will respond to the resolution of the player's screen, however, any pictures you have (such as a menu made with pictures, or any other, will still have the same resolution (number of pixels per width and height...)). Also, a game should be hand-made for each specific resolution, otherwise, you risk having the screen too far away from the character to compensate for large resolutions, thus resulting in a very ugly game.
In the alternative, I suggest using one of the most common resolutions around (width and height with the 16:9 ratio!)
You could even add a menu to your game with 3 or 4 different resolutions for the player to choose from (just like real computer games do). This way you can craft the pictures and the game accordingly so that it always looks good.