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.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Disable Yahoo Search Result URL Redirector
// @namespace    https://greasyfork.org/en/users/85671-jcunews
// @version      1.0.2
// @license      AGPLv3
// @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.
// @author       jcunews
// @match        *://*.yahoo.??/*
// @match        *://*.yahoo.co.??/*
// @match        *://*.yahoo.com/*
// @match        *://*.yahoo.com.??/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(() => {
  function patchYUI() {
    if (YUI.add.DYSRUR) return;
    var ya = YUI.add;
    YUI.add = function(a) {
      if (a === "srp-session-tracking") return;
      return ya.apply(this, arguments);
    };
    YUI.add.DYSRUR = true;
  }
  addEventListener("mousedown", ev => {
    if ((ev.target.tagName === "A") && ev.target.parentNode && ev.target.parentNode.matches("h3.title")) {
      ev.stopImmediatePropagation();
      ev.stopPropagation();
    }
  }, true);
  addEventListener("load", () => {
    if (window.YUI) {
      patchYUI();
      var ac = Node.prototype.appendChild;
      Node.prototype.appendChild = function(a) {
        patchYUI();
        return ac.apply(this, arguments);
      };
      var ib = Node.prototype.insertBefore;
      Node.prototype.insertBefore = function(a) {
        patchYUI();
        return ib.apply(this, arguments);
      };
    }
    document.querySelectorAll('a').forEach((a,b) => {
      if (
        (b = a.href.match(/\/\/r\.search\.yahoo\.com\/.*=((?:https?|ftp)[^/&]+)/)) ||
        (b = a.href.match(/yahoo\.com\/.*rurl=((?:https?|ftp)[^&]+)/))
      ) {
        a.href = decodeURIComponent(b[1]);
        a.rel += (a.rel && " ") + "noreferrer";
      }
    });
  })
})();