Skip to content

Instantly share code, notes, and snippets.

@trinhtuanvubk
Created August 5, 2024 02:55
Show Gist options
  • Select an option

  • Save trinhtuanvubk/d4fac56d7d5bc71cace5789baa76218f to your computer and use it in GitHub Desktop.

Select an option

Save trinhtuanvubk/d4fac56d7d5bc71cace5789baa76218f to your computer and use it in GitHub Desktop.
keep colab alive
Open the devtools and copy & paste to run the scrips.
const ping = () => {
const btn = document.querySelector("colab-connect-button");
const inner_btn = btn.shadowRoot.querySelector("#connect");
if (inner_btn) {
inner_btn.click();
console.log("Clicked on connect button");
} else {
console.log("connect button not found");
}
const nextTime = 50000 + Math.random() * 10000;
setTimeout(ping, nextTime);
};
ping();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment