Disable Google Search Result URL Redirector

Disable Google URL redirector (i.e. user data tracking) on Google Search result, including Google Custom Search Engine (CSE) which is used by many websites.

Stan na 13-10-2017. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Disable Google Search Result URL Redirector
// @namespace   DisableGoogleSearchResultURLRedirector
// @description Disable Google URL redirector (i.e. user data tracking) on Google Search result, including Google Custom Search Engine (CSE) which is used by many websites.
// @version     1.0.2
// @author      jcunews
// @include     *://*/*
// @grant       none
// @run-at      document-start
// ==/UserScript==

(function() {
    var orgCreateElement;

    //wait for CSE to finish its initialization
    function waitCse() {
      if (window.google && google.search && google.search.B && google.search.B.prototype.Fq) {
        //disable redirector
        google.search.B.prototype.Fq = function(){};
      } else setTimeout(waitCse, 20);
    }

    //check if newly loaded script is CSE
    function checkCse(ev) {
      if (window.__gcse) {
        document.createElement = orgCreateElement;
        waitCse();
      }
    }

    if ((/www\.google\.[a-z]+(\.[a-z]+)?/).test(location.hostname)) {
      //Google website: disable URL redirector generator function
      (function check() {
        if (window.rwt) {
          window.rwt = function() { return true };
        } else setTimeout(check, 10);
      })();
    } else {
      //other websites:
      //monitor for any CSE initialization
      orgCreateElement = document.createElement;
      document.createElement = function(tag) {
        var res = orgCreateElement.apply(this, arguments);
        if (tag.toLowerCase() === "script") res.addEventListener("load", checkCse);
        return res;
      };
      //disable ads
      HTMLElement.prototype.insertBefore = function(ele) {
        if ((/:\/\/cse\.google\.com\/adsense\/search\/(async-)?ads\.js/).test(ele.src)) return ele;
        return Node.prototype.insertBefore.apply(this, arguments);
      };
    }
})();