I need to run certain command "Run all" from Google Colab menu "Runtime" programmatically. It does not have any obvious "onclick" eventHandler which I could call from javascript code on that page. Other "divs" on the page are OK to be called from js, for exapmle, I can connect to runtime using js code:
document.querySelector('#top-toolbar > colab-connect-button').shadowRoot.querySelector('#connect').click();
Runtime menu is a dropdown menu and I tried to .click() every <div> item inside it but no effect.
Also "Run all" command has a hotkey Ctrl + F9 but dispatching event to the document element has no effect. But I can send Enter command to any input field inside the notebook with this code:
document.querySelector('input.raw_input').dispatchEvent(new KeyboardEvent('keydown', {key: 'Enter'}))
Using Chrome code inspector Ctrl + Shift + I I looked inside "Run all" command and it looks like:
<div command="runall" class="goog-menuitem" role="menuitem" id=":1w" style="user-select: none;"><div class="goog-menuitem-content" style="user-select: none;">Run all<span class="goog-menuitem-accel">Ctrl+F9</span></div></div>
So I searched inside Sources tab of inspector code on the page and found occurrences of "runall" in https://colab.research.google.com/v2/external/external_polymer_binary.js file:
, Eja = X(new W({
        id: "runall",
        description: "Run all cells in notebook",
        shortcut: IG(120)
120 - is a keycode of F9 button by the way. Also I found I think exact place where needed menu item is called:
        case "runall":
            d.runAll();
            break;
but it's almost impossible for me to understand what is d. and where its reference!
Also I found many other interesting and useful commands like this.notebook.getKernel().isRunning() or c.notebook.getKernel().restart() but the question is the same all the time: what is the root object for those commands? I tried document. and window. but the result is "undefined" or "is not a function". I think that I could call runall() command in a string like:
document.**SOMETHING I DONT KNOW**.runAll()
I am very bad with frontend/js and its very difficult to find something in obfuscated code but if we have such function as .runAll() in javascript code which is connected to required menu item I thick it is possible to run it programmatically from console or javascript injection
Or maybe it is possible to dispatch a keyboard event Ctrl + F9 to some element in order to run this command thus the question is WHAT is the required object to dispatch the keyboard event
 
    