With the following (GreaseMonkey) user script I am trying to find (and later access) a JavaScript object (namely 'Blazor'):

```js
// ==UserScript==
// @name         Test
// @version      1
// @grant        none
// @run-at       document-end
// ==/UserScript==

window.addEventListener ("load", doStuff);

function doStuff() { 
    setTimeout(function() {
        console.log("window.hasProperty('Blazor'): " + window.hasOwnProperty("Blazor"));
        console.log("'Blazor' in window:           " + ('Blazor' in window));
        console.log(window);
    }, 2000);    
}

```

When I run the script (i.e., reload the page), I get the following output in Firefox' console:

[![Screenshot of the Firefox JavaScript console](https://i.stack.imgur.com/2JDF1.png)](https://i.stack.imgur.com/2JDF1.png)

So `window.Blazor` can not be found. However, when I inspect (click on) the `window` object I can see the `Blazor` property:

[![Screenshot of the Firefox JavaScript console](https://i.stack.imgur.com/Hdmd4.png)](https://i.stack.imgur.com/Hdmd4.png)

Calling `'Blazor' in window` in the console also returns `true`.

Why is this property of `window` not (yet?) available and how can I find and access it?

**Update:**

Based on [madalinivascu's answer](https://stackoverflow.com/a/68014782/1824721) I tried the following:

```
function doStuff() {
  console.log("<doStuff>");

  var promise = new Promise(function(resolve, reject) {
    var interval = setInterval(function() {
      console.log("checking for Blazor");
      if ('Blazor' in window) {
        console.log("Blazor found");
        clearInterval(interval);
        resolve(window.Blazor);
      }
    }, 1000);
  });

  promise.then(successCallback, failureCallback);

  console.log("</doStuff>");
}

function failureCallback(error) {
  console.log("failure: " + error);
}

function successCallback(result) {
  console.log("success: " + result);
}

```

which results in the following output:

[![Screenshot of the Firefox console](https://i.stack.imgur.com/8JZy9.png)](https://i.stack.imgur.com/8JZy9.png)

So the function checking for Blazor is called indefinitely without success in finding it.