Sorry Google

Offer link with the search query to DuckDuckGo on Google sorry captcha pages

当前为 2024-03-30 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Sorry Google
// @namespace    https://github.com/appel/userscripts
// @version      0.2
// @description  Offer link with the search query to DuckDuckGo on Google sorry captcha pages
// @author       Ap
// @match        https://www.google.com/sorry/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const extractQuery = (url) => {
        const match = url.match(/%26q%3D(.*?)(&|$)/);
        if (match && match[1]) {
            return decodeURIComponent(match[1].replace(/\+/g, ' '));
        }
        return '';
    };

    if (window.location.href.startsWith('https://www.google.com/sorry')) {
        const query = extractQuery(window.location.href);
        const ddgUrl = `https://duckduckgo.com/?q=${query}`;
        const link = document.createElement('a');
        link.href = ddgUrl;
        link.textContent = 'Nah fam, take search to DuckDuckGo';
        link.style.display = 'inline-block';
        link.style.marginTop = '1rem';
        link.style.padding = '0.5rem 1rem';
        link.style.backgroundColor = '#de5833';
        link.style.color = '#ffffff';
        link.style.borderRadius = '5px';
        link.style.textDecoration = 'none';
        link.style.fontFamily = '-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif';
        link.style.fontSize = '18px';
        document.body.appendChild(link);
    }
})();