This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Show hidden characters if ( okTXT . indexOf ( "Reconnect" ) !== - 1 || okTXT . indexOf ( "RECONNECT" ) !== - 1 || okTXT . indexOf ( "Connect" ) !== - 1 || okTXT . indexOf ( "connect" ) !== - 1 || okTXT . indexOf ( "CONNECT" ) !== - 1 || okTXT . indexOf ( "Yeniden bağlan" ) !== - 1 || okTXT . indexOf ( "Bağlan" ) !== - 1 || okTXT . indexOf ( "Yeniden Bağlan" ) !== - 1 ) { console . log ( '> Colab Stay Alive Reconnecting...' ) ; ok . click ( ) ; console . log ( '> Colab Stay Alive Connected.' ) ;

run the following code in the console and it will prevent you from disconnecting.

  • Ctrl+ Shift + i to open inspector view .
  • go to console.
  • function ClickConnect(){
        console.log("Working"); 
        document.querySelector("colab-toolbar-button#connect").click() 
    setInterval(ClickConnect,60000)
    

    Also this can be done by

    function ColabReconnect() {
        var dialog = document.querySelector("colab-dialog.yes-no-dialog");
        var dialogTitle = dialog && dialog.querySelector("div.content-area>h2");
        if (dialogTitle && dialogTitle.innerText == "Runtime disconnected") {
            dialog.querySelector("paper-button#ok").click();
            console.log("Reconnecting...");
        } else {
            console.log("ColabReconnect is in service.");
    timerId = setInterval(ColabReconnect, 60000);
    

    Another and better thing instead of clicking the connect button is click on comment button to keep my session alive

    function ClickConnect(){
    console.log("Working"); 
    document.querySelector("#comments > span").click() 
    setInterval(ClickConnect,5000)
    

    Another creative option is to keep clicking "Refresh folder" in the file explorer pane

    function ClickRefresh(){
      console.log("Working"); 
      document.querySelector("[icon='colab:folder-refresh']").click()
    const myjob = setInterval(ClickRefresh, 60000)