Detect the browser

I’d like to restrict the browser that participants use because my experiment has compatibility problem with Brave and potentially others. I use the code following to trace the browser:
psychoJS.experiment.addData(“Browser”, window.navigator.userAgent);

But after testing, it doesn’t correctly distinguish some browsers like Brave. The returned value is the same as Chrome:
Brave: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36
Chrome: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Does anyone any suggestions on how to correctly record the browser participants are using and quit the experiment immediately if certain types of browsers are detected?

Thank you!


Since the returned value is identical, could you add a question which addresses the compatibility issue. What doesn’t work on Brave?

The position of text is weird and there are some overlapping within different text stimuli.

Also the size and location of images are not the optimal:In the Begin Experiment phase, I read screen.width and screen.height to arrange three images in a line, adding spacing between them and the screen edges. But in Brave the images align to the edges with no gap.
In Brave: (no space between images on the sides and the screen edges)

The normal alignment in Chrome/Firefox: (with space gap on sides)

Thank you for the further help.

Try reading screen height and width in End Routine of the first routine.

Also, I use win.size[0] and win.size[1] instead of screen.width and screen.height

win.size auto translates to psychoJS.window.size

Thanks for the advice!

However when I tried to put the codes on End Routine of the first routine, the images can not be loaded correctly:

At first I tried to read the screen size with psychoJS.window.size[0] and psychoJS.window.size[1]; but images would align with the edges of the screen somehow. If I read with screen.width and screen.height the images would align correctly with spaces on both sides.

You will need to set sizes each repeat rather than constant for this to work

Thanks! I will modify the codes to see how it goes. Just to clarify a bit, what’s the difference between screen.width and psychoJS.window.size[0]?