Sorry, Google!

Offer link to take search to DuckDuckGo on the "/sorry" captcha pages Google serves when you use a VPN.

目前為 2024-04-13 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Sorry, Google!
// @namespace    https://github.com/appel/userscripts
// @version      0.3
// @description  Offer link to take search to DuckDuckGo on the "/sorry" captcha pages Google serves when you use a VPN.
// @author       Ap
// @match        https://www.google.com/sorry/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const extractQuery = (url) => {
        const match = url.match(/q%3D(.*?)%26|q%3D(.*?)(?=&|$)/);
        if (match) {
            const queryComponent = match[1] || match[2];
            return decodeURIComponent(queryComponent.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 = '#c7643b';
        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);
    }
})();