Skip to content

Instantly share code, notes, and snippets.

@GrayXu
Created January 16, 2026 09:07
Show Gist options
  • Select an option

  • Save GrayXu/557113521717b3c26abb87114a352d8f to your computer and use it in GitHub Desktop.

Select an option

Save GrayXu/557113521717b3c26abb87114a352d8f to your computer and use it in GitHub Desktop.
油猴脚本 Google Scholar 拦截自动跳转 (Bypass Google Sorry)
// ==UserScript==
// @name Google Scholar 拦截自动跳转 (Bypass Google Sorry)
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 当 Google Scholar 提示流量异常时,如果 URL 中包含最终跳转目标,自动提取并跳转,不再尝试验证 CAPTCHA。
// @author GrayXu
// @match https://www.google.com/sorry/index*
// @match https://ipv4.google.com/sorry/index*
// @match https://google.com/sorry/index*
// @run-at document-start
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 1. 获取当前拦截页面的 URL 参数
const currentParams = new URLSearchParams(window.location.search);
const continueUrlString = currentParams.get('continue');
// 如果没有 continue 参数,说明无法得知下一步要去哪,停止运行
if (!continueUrlString) return;
try {
// 2. 解析 continue 参数中的 URL (通常是 https://scholar.google.com/scholar_url?url=...)
const continueUrl = new URL(continueUrlString);
// 3. 尝试从 scholar_url 中提取真实的 'url' 参数
// 你的例子中:scholar_url?url=https://raw.github...
const finalDestination = continueUrl.searchParams.get('url');
if (finalDestination) {
// 找到最终目标 (PDF/网页),直接跳转,完全避开 Google
console.log('已检测到 Google Scholar 拦截,正在直接跳转至目标:', finalDestination);
// 为了防止页面闪烁太快看不清,这里用 replace 直接替换历史记录,或者用 href
window.location.href = finalDestination;
} else {
// 边缘情况:如果 continue 只是回到搜索结果页而不是具体的文章链接
// 这种情况下跳转回去通常还是会被拦截,所以这里选择不操作,或者你可以选择打印日志
console.log('未在跳转链接中发现目标 URL,这可能是一个普通的搜索页面拦截。');
}
} catch (e) {
console.error('跳转脚本解析出错:', e);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment