如何避免colab因为长时间不点击而“忙碌”掉线
程序员文章站
2022-03-23 11:17:49
在谷歌浏览器按Ctrl+ Shift + i (Mac:command + option + i),将下面的代码输入Console并回车即可function ConnectButton(){ console.log("Connect pushed"); document.querySelector("#connect").click() }setInterval(ConnectButton,60000);......
在谷歌浏览器按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