Disable Yahoo Search Result URL Redirector

Disable Yahoo URL redirector (i.e. user data tracking) on Yahoo Search result, and ensures that the referring URL (i.e. the search page) is not sent to the target site. This script also disable link tracking that let Yahoo knows which off-site link the user is clicking.

当前为 2019-04-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Disable Yahoo Search Result URL Redirector
  3. // @namespace https://greasyfork.org/en/users/85671-jcunews
  4. // @version 1.0.1
  5. // @license AGPLv3
  6. // @description Disable Yahoo URL redirector (i.e. user data tracking) on Yahoo Search result, and ensures that the referring URL (i.e. the search page) is not sent to the target site. This script also disable link tracking that let Yahoo knows which off-site link the user is clicking.
  7. // @author jcunews
  8. // @match *://*.yahoo.??/*
  9. // @match *://*.yahoo.co.??/*
  10. // @match *://*.yahoo.com/*
  11. // @match *://*.yahoo.com.??/*
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (() => {
  16. function patchYUI() {
  17. if (YUI.add.DYSRUR) return;
  18. var ya = YUI.add;
  19. YUI.add = function(a) {
  20. if (a === "srp-session-tracking") return;
  21. return ya.apply(this, arguments);
  22. };
  23. YUI.add.DYSRUR = true;
  24. }
  25. if (window.YUI) {
  26. patchYUI();
  27. var ac = Node.prototype.appendChild;
  28. Node.prototype.appendChild = function(a) {
  29. patchYUI();
  30. return ac.apply(this, arguments);
  31. };
  32. var ib = Node.prototype.insertBefore;
  33. Node.prototype.insertBefore = function(a) {
  34. patchYUI();
  35. return ib.apply(this, arguments);
  36. };
  37. }
  38. document.querySelectorAll('a').forEach((a,b) => {
  39. if (
  40. (b = a.href.match(/\/\/r\.search\.yahoo\.com\/.*=((?:https?|ftp)[^/&]+)/)) ||
  41. (b = a.href.match(/yahoo\.com\/.*rurl=((?:https?|ftp)[^&]+)/))
  42. ) {
  43. a.href = decodeURIComponent(b[1]);
  44. a.rel += (a.rel && " ") + "noreferrer";
  45. }
  46. });
  47. })();