解除谷歌“手气不错”、知乎链接的重定向(使用Deepseek 优化)

谷歌手气不错以及知乎会阻止跳转网站,此脚本用于解决此问题。

  1. // ==UserScript==
  2. // @name 解除谷歌“手气不错”、知乎链接的重定向(使用Deepseek 优化)
  3. // @name:zh-CN 解除谷歌“手气不错”、知乎链接的重定向(使用Deepseek 优化)
  4. // @name:en-US Solve Google I'm Feeling Lucky Redirect Problem/ Zhihu Redirect Problem
  5. // @namespace SolveRedirect
  6. // @version 0.6
  7. // @author Bilibili Up 漫游挨踢
  8. // @include *google.*/*
  9. // @include *link.zhihu.com/*
  10. // @grant none
  11. // @description:zh-cn 谷歌手气不错以及知乎会阻止跳转网站,此脚本用于解决此问题。
  12. // @description:en-US Google 's I'm feeling Lucky and Zhihu will cause redirect problem.This script will solve that.
  13. // @description 谷歌手气不错以及知乎会阻止跳转网站,此脚本用于解决此问题。
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. // 通用URI多重解码函数
  21. function fullyDecodeURIComponent(str) {
  22. let decoded = str;
  23. try {
  24. while (true) {
  25. const current = decodeURIComponent(decoded);
  26. if (current === decoded) break;
  27. decoded = current;
  28. }
  29. } catch (e) {
  30. // 解码出错时返回当前结果
  31. }
  32. return decoded;
  33. }
  34.  
  35. // 处理谷歌重定向
  36. if (location.hostname.includes('google.com') && location.pathname === '/url') {
  37. const urlParams = new URLSearchParams(location.search);
  38. const targetUrl = urlParams.get('q');
  39. if (targetUrl && (targetUrl.startsWith('http://') || targetUrl.startsWith('https://'))) {
  40. location.href = fullyDecodeURIComponent(targetUrl);
  41. }
  42. }
  43.  
  44. // 处理知乎重定向
  45. if (location.hostname === 'link.zhihu.com') {
  46. const urlParams = new URLSearchParams(location.search);
  47. const targetUrl = urlParams.get('target');
  48. if (targetUrl) {
  49. location.href = fullyDecodeURIComponent(targetUrl);
  50. }
  51. }
  52. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址