阅读:1483回复:0
求推荐"页面连接错误自动重试"脚本,或修改下现在这个不能用在GM上
求推荐一个页面连接错误/超时,自动刷新"的脚本,
或者哪位给看看这个脚本的问题 可以在scriptish上正常使用, 不能在greasemonkey上用,不知道为什么 又找了个Cye3s修改的同样功能的脚本,也是只能在scriptish上用,不能在gm上用, 求修改,谢谢. /* This nifty script will automatically reload a webpage. Eric Lammertsma */ // ==UserScript== // @name Server not found? Try and try again! // @description (2006-04-17) // @include * // ==/UserScript== (function () { if(document.documentURI.substr(0,14)=="about:neterror") { var text1 = "If at first you don't succeed, Try and..."; var text2 = "Try again!"; var text3 = "Canceled."; var error_div = document.getElementById("errorLongDesc"); var error_btn = document.getElementById("errorTryAgain"); if (error_div && error_btn) { var head = document.getElementsByTagName("head")[0]; script = document.createElement("script"); script.type = "application/x-javascript"; script.innerHTML = "var count=4;\nvar countdown=\"\";var auto_retry=true;\nsetTimeout(autoRetryThis, 1000);\nfunction autoRetryThis() {\nif (!auto_retry) {\ndocument.getElementById(\"errorAutoRetry3\").innerHTML = \""+text3+"\";\nreturn\n}\nif (count>0) {\ncount--;\nif (count>0) countdown += \" \"+count+\"..\"\nsetTimeout(autoRetryThis, 1000);\n}\ndocument.getElementById(\"errorAutoRetry2\").innerHTML = countdown;\nif (count <= 0){\ndocument.getElementById(\"errorAutoRetry3\").innerHTML = \""+text2+"\";\nretryThis();\n}\n}"; head.appendChild(script) error_div.innerHTML += "<p><div id=\"errorAutoRetry1\">"+text1+"</div><div id=\"errorAutoRetry2\" style=\"font-size:80%;color:ThreeDShadow;\"><br /></div><div id=\"errorAutoRetry3\"><br /></div></p>"; error_btn.style.marginTop = "0px"; error_btn.style.marginBottom = "5px"; // This *should* work, but it doesn't /* cancel_btn = document.createElement("xul:button"); cancel_btn.setAttribute("xmlns:xul", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); cancel_btn.setAttribute("id", "errorStopRetry"); cancel_btn.setAttribute("oncommand", "auto_retry=false; autoRetryThis();"); cancel_btn.setAttribute("label", "Stop Trying"); cancel_btn.setAttribute("style", "margin-top: 0px; color: -moz-FieldText; height:25px; width:100px;"); */ // So normal HTML instead: cancel_btn = document.createElement("button"); cancel_btn.setAttribute("id", "errorStopRetry"); cancel_btn.setAttribute("onclick", "auto_retry=false; this.style.visibility=\"hidden\"; autoRetryThis();"); cancel_btn.setAttribute("style", "margin-top: 5px; margin-bottom: 5px;"); cancel_btn.innerHTML = "Stop Trying"; error_btn.parentNode.appendChild(cancel_btn, error_btn); } } })(); // ==UserScript== // @name Try Again // @author Cye3s // @description (2008-05-23) Edit from http://userscripts.org/scripts/show/4125 // @include * // ==/UserScript== (function () { if(document.documentURI.substr(0,14)=="about:neterror") { var text1 = "正在重试..."; var text2 = "重试!"; var text3 = "取消"; var error_div = document.getElementById("errorLongDesc"); var error_btn = document.getElementById("errorTryAgain"); var securityOverride_Div = document.getElementById("securityOverrideDiv"); if (error_div && error_btn && !securityOverride_Div) { var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); script.type = "application/x-javascript"; script.innerHTML = "var count=3;\nvar countdown=\"\";\nvar auto_retry=true;\nsetTimeout(autoRetryThis, 1000);\nfunction autoRetryThis() {\nif (!auto_retry) {\ndocument.getElementById(\"errorAutoRetry3\").innerHTML = \""+text3+"\";\nreturn\n}\nif (count>0) {\ncount--;\nif (count>0) countdown += \" \"+count+\"..\"\nsetTimeout(autoRetryThis, 1000);\n}\ndocument.getElementById(\"errorAutoRetry2\").innerHTML = countdown;\nif (count <= 0){\ndocument.getElementById(\"errorAutoRetry3\").innerHTML = \""+text2+"\";\nretryThis(document.getElementById('errorTryAgain'));\n}\n}"; head.appendChild(script) error_div.innerHTML += "<p><div id=\"errorAutoRetry1\">"+text1+"</div><div id=\"errorAutoRetry2\" style=\"font-size:80%;color:ThreeDShadow;\"><br /></div><div id=\"errorAutoRetry3\"><br /></div></p>"; error_btn.style.marginTop = "0px"; error_btn.style.marginBottom = "5px"; var cancel_btn = document.getElementById("errorTryAgain").cloneNode(true); cancel_btn.setAttribute("id", "errorStopRetry"); cancel_btn.setAttribute("oncommand", "auto_retry=false; this.style.visibility=\"hidden\"; autoRetryThis();"); cancel_btn.setAttribute("label", "停止重试"); cancel_btn.setAttribute("style", "margin-top: 0px; margin-bottom: 5px;"); error_btn.parentNode.appendChild(cancel_btn); } } //if(document.title=="") { //window.location.reload(); //} })(); |
|
|