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.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==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";
      }
    });
  })
})();