I want to disable all alert errors for webgl

I want to disable the entire alert system that shows up with:
An error occurred running the Unity content on this page.

I'm using unity 2022.

I tried disabling the alert in a unityloader.js file I found in the webgl build folder but that didn't work.
I also tried this but it didn't work either. I cleared my cache in my testing also.

UnityLoader.Error.handler = function(e,t){console.log(e);}

I'm not sure where it's even coming from in 2022.
Can someone tell me where the alert is coming from so I can change it to console.log?

The proper way to do that is to locate and fix these errors. ;)

Nice one...

While I strongly suggest to follow CodeSmile's advise on locating and fixing errors, there might be some scenerios when it's impossible.
For example, in my case if I abort WebRequest I recieve a noisy popup with the exception on Safari (MacOS) on Unity 2022.2.16f1. The exception comes from the inside of Unity, is never handled. I'm also unable to catch it anywhere. It's also important to note, that the exception is actually harmless and doesn't affect gameplay in any way with the exception of generating noisy popup.

So I've written following code which overrides default alert of javascript to suppress popup, but only for my exception. I still want to receive popups with alerts for other types of exceptions. The code itself may be placed anywhere where JavaScript code belongs, for example right above createUnityInstance method.

let builtInAlert = alert;
alert = function(message) {
    if (message != null && typeof(message) == "string") {
        if (message.indexOf("AbortError: Fetch is aborted") != -1) {
            console.log("Suppressed exception: \"AbortError: Fetch is aborted\"");

If you don't want to receive any exceptions as popups code becomes even simplier, but I advise you not to use it as it leaves you without a good tool to discover exceptions.

alert = function(message) {

Sorry, I'm not used to javascript so where can I apply this code? Is there a file in the depository or a script hidden somewhere?

You need to edit selected WebGL template. Here is a link with information.


If you are unfamilliar with .js, then I suggest you put code from above inside