Skip to content

Instantly share code, notes, and snippets.

@RodolfoFerro
Last active November 27, 2023 06:28
Show Gist options
  • Select an option

  • Save RodolfoFerro/a12c664330c6eae601e5a828adfb8306 to your computer and use it in GitHub Desktop.

Select an option

Save RodolfoFerro/a12c664330c6eae601e5a828adfb8306 to your computer and use it in GitHub Desktop.
Stop Colab from disconnecting, 2021.
function ClickConnect() {
console.log('Working')
document
.querySelector('#top-toolbar > colab-connect-button')
.shadowRoot.querySelector('#connect')
.click()
}
intervalTiming = setInterval(ClickConnect, 60000)
function ClickConnect(){
console.log('Working');
document.querySelector('colab-toolbar-button#toolbar-add-text').click();
}
intervalTiming = setInterval(ClickConnect, 60000);
@RodolfoFerro
Copy link
Copy Markdown
Author

RodolfoFerro commented Apr 5, 2021

These scripts help to stop Colab from disconnecting, in 2021.

The script in click_connect_button.js clicks the connect button every minute.
The script in create_text_cell.js just adds a text cell by clicking the toolbar every minute.

you can modify the time in the setInterval function.

@Elzic6
Copy link
Copy Markdown

Elzic6 commented May 6, 2021

Thks, works well :)
but how to stop it afterwork ?
best,

@RodolfoFerro
Copy link
Copy Markdown
Author

Hello @Elzic6!

Since we created the variable intervalTiming, we can just stop it by doing:

clearInterval(intervalTiming);

@sasagr
Copy link
Copy Markdown

sasagr commented Jul 20, 2021

now we are getting the message even with your script:
"Colab is for interactive use. Please confirm that you are present to continue"
Any workaround?

@Mspy1
Copy link
Copy Markdown

Mspy1 commented Oct 3, 2021

Any updates on this?

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