That's probably DRM protected content, it's not Javascript hack but a mecahnism that's built in deeper. A high level overview of how it works on Android is here(the secure texture part):
https://source.android.com/devices/graphics/arch-st#st_vid_p...
I'm not sure what the implementation is on Chrome/Desktop; probably something similar.
Chrome has the Widevine DRM built into it. Since 2017 users cannot disable it.
Try OBS Studio if you want to do screen capture.
The workaround of pointing/recording content using a mobile camera is guaranteed to always work regardless of any flimsy DRM scheme these vendors implement [0].
[0] https://en.wikipedia.org/wiki/Analog_hole