百度查询链接自动添加关键词' -robin'

1.02更新内容 新增后缀为“+-robin”的匹配

  1. // ==UserScript==
  2. // @name 百度查询链接自动添加关键词' -robin'
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.02
  5. // @description 1.02更新内容 新增后缀为“+-robin”的匹配
  6. // @description 为百度搜索链接自动添加" -robin"后缀,可屏蔽大部分百度推广
  7. // @author leeannm
  8. // @match https://www.baidu.com/s?*
  9. // @match https://www.baidu.com/*/s?*
  10. // @match https://m.baidu.com/s?*
  11. // @match https://m.baidu.com/*/s?*
  12. // @license MIT
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. // 获取当前URL
  20. var currentUrl = window.location.href;
  21.  
  22. // 检查URL是否包含wd参数
  23. if (currentUrl.includes('wd=') || currentUrl.includes('word=')) {
  24. var wdParamIndex = 0;
  25. if (currentUrl.includes('wd=')) {
  26. // 获取wd参数的值
  27. wdParamIndex = currentUrl.indexOf('wd=') + 3;
  28. }
  29. else {
  30. // 获取word参数的值
  31. wdParamIndex = currentUrl.indexOf('word=') + 5;
  32. }
  33. var wdValueEndIndex = currentUrl.indexOf('&', wdParamIndex) !== -1 ? currentUrl.indexOf('&', wdParamIndex) : currentUrl.length;
  34. var wdValue = currentUrl.substring(wdParamIndex, wdValueEndIndex);
  35.  
  36. // 检查wd值是否以"%20-robin" 或 " -robin" 或 "+-robin"结尾
  37. if (!wdValue.endsWith('%20-robin') && !wdValue.endsWith(' -robin') && !wdValue.endsWith('+-robin')) {
  38. // 添加" -robin"后缀
  39. var newWdValue = wdValue + ' -robin';
  40.  
  41. // 构建新的URL
  42. var newUrl = currentUrl.substring(0, wdParamIndex) + newWdValue + currentUrl.substring(wdValueEndIndex);
  43.  
  44. // 重定向到新的URL
  45. window.location.href = newUrl;
  46. }
  47. }
  48. })();

QingJ © 2025

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