Sorry, Google!

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

当前为 2024-04-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Sorry, Google!
  3. // @namespace https://github.com/appel/userscripts
  4. // @version 0.3
  5. // @description Offer link to take search to DuckDuckGo on the "/sorry" captcha pages Google serves when you use a VPN.
  6. // @author Ap
  7. // @match https://www.google.com/sorry/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const extractQuery = (url) => {
  16. const match = url.match(/q%3D(.*?)%26|q%3D(.*?)(?=&|$)/);
  17. if (match) {
  18. const queryComponent = match[1] || match[2];
  19. return decodeURIComponent(queryComponent.replace(/\+/g, ' '));
  20. }
  21. return '';
  22. };
  23.  
  24. if (window.location.href.startsWith('https://www.google.com/sorry')) {
  25. const query = extractQuery(window.location.href);
  26. const ddgUrl = `https://duckduckgo.com/?q=${query}`;
  27. const link = document.createElement('a');
  28. link.href = ddgUrl;
  29. link.textContent = 'Nah fam, take search to DuckDuckGo';
  30. link.style.display = 'inline-block';
  31. link.style.marginTop = '1rem';
  32. link.style.padding = '0.5rem 1rem';
  33. link.style.backgroundColor = '#c7643b';
  34. link.style.color = '#ffffff';
  35. link.style.borderRadius = '5px';
  36. link.style.textDecoration = 'none';
  37. link.style.fontFamily = '-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif';
  38. link.style.fontSize = '18px';
  39. document.body.appendChild(link);
  40. }
  41. })();