如何避免colab因为长时间不点击而“忙碌”掉线

2022-07-28,,,

在谷歌浏览器按Ctrl+ Shift + i (Mac:command + option + i),将下面的代码输入Console并回车即可

function ConnectButton(){
    console.log("Connect pushed"); 
    document.querySelector("#connect").click() 
}
setInterval(ConnectButton,60000);

之前的好像不咋好用 现在变成这样
star()开始
stop()结束

function getElementByXpath(path) {
       return document.evaluate(path, document, null, 
       XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  }
 
function reconnect(){
	  console.log('working')
	  getElementByXpath("//div[@id='top-toolbar']/colab-connect-button").click()
}
var a = setInterval(reconnect, 1*60*1000);
function stop(){
	 clearInterval(a)
}
function start(){
	 a = setInterval(reconnect, 1*60*1000);
}

本文地址:https://blog.csdn.net/weixin_45637875/article/details/109381018

《如何避免colab因为长时间不点击而“忙碌”掉线.doc》

下载本文的Word格式文档,以方便收藏与打印。