Skip to content

Instantly share code, notes, and snippets.

@cheeyeo
Forked from josepdecid/ColabReconnect.js
Created March 13, 2023 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheeyeo/612ce7786226183bd939b5c7700679f6 to your computer and use it in GitHub Desktop.
Save cheeyeo/612ce7786226183bd939b5c7700679f6 to your computer and use it in GitHub Desktop.
Colab Reconnect
// Interval time to check if runtime is disconnected
interval = 1000 * 60;
// Busy/Reconnect button top-right
reloadButton = document.querySelector('#connect > paper-button > span')
setInterval(() => {
if (reloadButton.innerText == 'Reconnect') {
reloadButton.click();
console.log('Restarting');
} else console.log('Keeps working');
}, interval);
@cheeyeo
Copy link
Author

cheeyeo commented Mar 13, 2023

@cheeyeo
Copy link
Author

cheeyeo commented Mar 13, 2023

function ClickConnect(){
console.log("Working"); 
document.querySelector("colab-toolbar-button#toolbar-add-text").click() 
}setInterval(ClickConnect,120000)

@cheeyeo
Copy link
Author

cheeyeo commented Mar 13, 2023

The current js snippet that works:

function ConnectButton(){
    console.log("Connect pushed"); 
    document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click() 
}
setInterval(ConnectButton,600000); //600 seconds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment