Find position of cursor in monaco editor from window object

I am trying to find the cursor position in an editor instance of a monaco editor on the page that has already been created. I am doing this through a browser extension so I don’t have access to the code that created the editor.

I just want to find the position of the cursor in the editor. But for that I need to somehow get the instance of the editor on the page.

Can I somehow do this using a combination of the model and the DOM element of the editor?

I can see there is a monaco.editor property on window but window.monaco.editor.getEditors() is not a function.

const model = monaco.editor.getModels()[0]; // Returns the actual model used on the page

const container = document.querySelector(".monaco-editor").parentElement; // the editor in the DOM

const editorInstance = window.monaco.editor.getEditors(); // Not a function