Skip to content

Instantly share code, notes, and snippets.

@glasslion
Last active October 14, 2016 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glasslion/a94ca3651651ed9e540e9343c85d3bc7 to your computer and use it in GitHub Desktop.
Save glasslion/a94ca3651651ed9e540e9343c85d3bc7 to your computer and use it in GitHub Desktop.
当 Google 搜索遇到 We're sorry... 时, 自动刷新页面重试 的油猴脚本
// ==UserScript==
// @name Retry Google Sorry
// @description 当 Google 搜索遇到 We're sorry... 时, 自动刷新页面重试, 使用代理访问 Google 时, 常遇到这种现象
// @namespace https://gist.github.com/glasslion
// @author glasslion
// @include http*://ipv4.google.com/sorry/index?*
// @version 1.2
// @run-at document-end
// @grant none
// ==/UserScript==
var body = document.getElementsByTagName('body')[0];
if (body.innerHTML.indexOf("To protect our users, we can't process your request right now.") !== -1){
//没有验证码时刷新
location.reload();
}
function checkCaptcha() {
var captcha = document.getElementsByTagName('img')[0];
if (typeof captcha.naturalWidth !== "undefined" && captcha.naturalWidth === 0) {
//验证码加载失败时刷新
location.reload();
}
}
// 2秒后,若验证码还没加载好
setTimeout(checkCaptcha, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment